/// <summary> /// The process. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <param name="context"> /// The context. /// </param> /// <param name="bitmap"> /// The bitmap. /// </param> /// <returns> /// The process. /// </returns> public bool Process(IImageParameters parameters, HttpContext context, ref Bitmap bitmap) { if (parameters.Parameters.ContainsKey("watermark")) { string watermarkParameter = parameters["watermark"]; if (string.IsNullOrEmpty(watermarkParameter)) { return(false); } float fontSize = 15; if (!string.IsNullOrEmpty(parameters["watermark_fontsize"])) { fontSize = (float)Convert.ToDouble(parameters["watermark_fontsize"]); } int alpha = 20; if (!string.IsNullOrEmpty(parameters["watermark_opacity"])) { alpha = Convert.ToInt32(parameters["watermark_opacity"]); } Color color = Color.White; if (!string.IsNullOrEmpty(parameters["watermark_color"])) { color = Color.FromName(parameters["watermark_color"]); } IImageTool imageTool = Factory.GetImageTool(); bitmap = imageTool.Watermark(bitmap, watermarkParameter, fontSize, alpha, color); return(true); } return(false); }
public ExternalController(IWebHostEnvironment _hostEnv, IUtilidad _util, IGaleriaGirlsRepository _galeriaGirls, IGirlsRepository _girls, IAppLogRepository _log, IImageTool _imageTool, IGaleriaGirlsAudioRepository _galeriaGirlsAudio) { util = _util; hostEnv = _hostEnv; girls = _girls; galeriaGirls = _galeriaGirls; galeriaGirlsAudio = _galeriaGirlsAudio; imageTool = _imageTool; log = _log; }
public Adjustment(IImageTool tool) { if (tool == null) { throw new Exception("Tool reference is null."); } this._isEnabled = true; this._imageTool = tool; this._startImage = null; this._endImage = null; }
/// <summary> /// The process. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <param name="context"> /// The context. /// </param> /// <param name="bitmap"> /// The bitmap. /// </param> /// <returns> /// The process. /// </returns> public bool Process(IImageParameters parameters, HttpContext context, ref Bitmap bitmap) { if (parameters.Parameters.ContainsKey("rotate")) { string rotateParameter = parameters.Parameters["rotate"]; float angle; if (float.TryParse(rotateParameter, NumberStyles.Float, CultureInfo.InvariantCulture, out angle)) { IImageTool imageTool = Factory.GetImageTool(); bitmap = imageTool.Rotate(bitmap, angle); return(true); } } return(false); }
/// <summary> /// The process. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <param name="context"> /// The context. /// </param> /// <param name="bitmap"> /// The bitmap. /// </param> /// <returns> /// The process. /// </returns> public bool Process(IImageParameters parameters, HttpContext context, ref Bitmap bitmap) { if (parameters.Parameters.ContainsKey("greyscale")) { string greyScaleParameter = parameters.Parameters["greyscale"]; if (string.IsNullOrEmpty(greyScaleParameter)) { return(false); } IImageTool imageTool = Factory.GetImageTool(); bitmap = imageTool.ToGreyScale(bitmap); return(true); } return(false); }
/// <summary> /// The process. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <param name="context"> /// The context. /// </param> /// <param name="bitmap"> /// The bitmap. /// </param> /// <returns> /// The process. /// </returns> public bool Process(IImageParameters parameters, HttpContext context, ref Bitmap bitmap) { if (parameters.Parameters.ContainsKey("zoom")) { string zoomParameter = parameters.Parameters["zoom"]; float zoomFactor; if (float.TryParse(zoomParameter, NumberStyles.Float, CultureInfo.InvariantCulture, out zoomFactor)) { IImageTool imageTool = Factory.GetImageTool(); bitmap = imageTool.Zoom(bitmap, zoomFactor); return(true); } } return(false); }
/// <summary> /// The get image tool. /// </summary> /// <returns> /// </returns> /// <exception cref="ConfigurationErrorsException"> /// </exception> public static IImageTool GetImageTool() { if (s_ImageTool.IsNull()) { lock (s_SyncLock) { if (s_ImageTool.IsNull()) { Type imageToolType = Type.GetType(Settings.Default.ImageToolType); if (imageToolType.IsNull()) { throw new ConfigurationErrorsException( string.Format("Unable to resolve image tool type: {0}", Settings.Default.ImageToolType)); } s_ImageTool = Activator.CreateInstance(imageToolType) as IImageTool; } } } return(s_ImageTool); }
/// <summary> /// The process. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <param name="context"> /// The context. /// </param> /// <param name="bitmap"> /// The bitmap. /// </param> /// <returns> /// The process. /// </returns> public bool Process(IImageParameters parameters, HttpContext context, ref Bitmap bitmap) { if (parameters.Parameters.ContainsKey("width") || parameters.Parameters.ContainsKey("height")) { string widthParameter = parameters.Parameters.ContainsKey("width") ? parameters.Parameters["width"] : string.Empty; string heightParameter = parameters.Parameters.ContainsKey("height") ? parameters.Parameters["height"] : string.Empty; int imageResizeWidth = 0; int imageResizeHeight = 0; // Preserve aspect only if either width or height is specified, not both. if (!string.IsNullOrEmpty(widthParameter)) { int width; if (int.TryParse(widthParameter, out width)) { imageResizeWidth = width; } } if (!string.IsNullOrEmpty(heightParameter)) { int height; if (int.TryParse(heightParameter, out height)) { imageResizeHeight = height; } } if (imageResizeWidth == 0 && imageResizeHeight == 0) { imageResizeWidth = bitmap.Width; imageResizeHeight = bitmap.Height; } bool constrainImageSize = true; if (!string.IsNullOrEmpty(parameters["resize_constrain"])) { bool.TryParse(parameters["resize_constrain"], out constrainImageSize); } bool keepSquare = false; if (!string.IsNullOrEmpty(parameters["resize_square"])) { bool.TryParse(parameters["resize_square"], out keepSquare); } Color bgColor = Color.White; if (!string.IsNullOrEmpty(parameters["resize_bgcolor"])) { bgColor = Color.FromName(parameters["resize_bgcolor"]); } IImageTool imageTool = Factory.GetImageTool(); bitmap = imageTool.Resize(bitmap, imageResizeWidth, imageResizeHeight, constrainImageSize, keepSquare, bgColor); return(true); } return(false); }
public TestController(IWebHostEnvironment _hostEnv, IImageTool _imageTool) { hostEnv = _hostEnv; imageTool = _imageTool; }