public XbrzScaler(XbrzScalerType type) { var info = cImage.GetPixelScalerInfo(type); this._type = type; this._scaleFactorX = info.Item1; this._scaleFactorY = info.Item2; }
/// <summary> /// Gets the pixel scaler info. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> internal static Tuple <byte, byte, XbrzFilter> GetPixelScalerInfo(XbrzScalerType type) { Tuple <byte, byte, XbrzFilter> info; if (XBRz_SCALERS.TryGetValue(type, out info)) { return(info); } throw new NotSupportedException(string.Format("XBRz scaler '{0}' not supported.", type)); }
/// <summary> /// Gets the scaler information. /// </summary> /// <param name="type">The type of XBR scaler.</param> /// <returns></returns> /// <exception cref="System.NotSupportedException"></exception> public static ScalerInformation GetScalerInformation(XbrzScalerType type) { Tuple <byte, byte, XbrzFilter> info; if (XBRz_SCALERS.TryGetValue(type, out info)) { return(new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2)); } throw new NotSupportedException(string.Format("XBRz scaler '{0}' not supported.", type)); }
/// <summary> /// Applies the XBR pixel scaler. /// </summary> /// <param name="type">The type of scaler to use.</param> /// <param name="filterRegion">The filter region, if any.</param> /// <returns> /// The rescaled image. /// </returns> public cImage ApplyScaler(XbrzScalerType type, Rectangle? filterRegion = null) { var info = GetPixelScalerInfo(type); var scaleX = info.Item1; var scaleY = info.Item2; var scaler = info.Item3; if (filterRegion == null) filterRegion = new Rectangle(0, 0, this.Width, this.Height); var result = new cImage(this.Width * scaleX, this.Height * scaleY); // TODO: generic pixel loop scaler(this.GetImageData(), result.GetImageData(), this.Width, this.Height, filterRegion.Value.Left, filterRegion.Value.Top, filterRegion.Value.Right, filterRegion.Value.Bottom); return (result); }
/// <summary> /// Applies the XBR pixel scaler. /// </summary> /// <param name="type">The type of scaler to use.</param> /// <param name="filterRegion">The filter region, if any.</param> /// <returns> /// The rescaled image. /// </returns> public cImage ApplyScaler(XbrzScalerType type, Rectangle?filterRegion = null) { var info = GetPixelScalerInfo(type); var scaleX = info.Item1; var scaleY = info.Item2; var scaler = info.Item3; if (filterRegion == null) { filterRegion = new Rectangle(0, 0, this.Width, this.Height); } var result = new cImage(this.Width * scaleX, this.Height * scaleY); // TODO: generic pixel loop scaler(this.GetImageData(), result.GetImageData(), this.Width, this.Height, filterRegion.Value.Left, filterRegion.Value.Top, filterRegion.Value.Right, filterRegion.Value.Bottom); return(result); }
/// <summary> /// Gets the scaler information. /// </summary> /// <param name="type">The type of XBR scaler.</param> /// <returns></returns> /// <exception cref="System.NotSupportedException"></exception> public static ScalerInformation GetScalerInformation(XbrzScalerType type) { Tuple<byte, byte, XbrzFilter> info; if (XBRz_SCALERS.TryGetValue(type, out info)) return (new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2)); throw new NotSupportedException(string.Format("XBRz scaler '{0}' not supported.", type)); }
/// <summary> /// Gets the pixel scaler info. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> internal static Tuple<byte, byte, XbrzFilter> GetPixelScalerInfo(XbrzScalerType type) { Tuple<byte, byte, XbrzFilter> info; if (XBRz_SCALERS.TryGetValue(type, out info)) return (info); throw new NotSupportedException(string.Format("XBRz scaler '{0}' not supported.", type)); }
/// <summary> /// Applies the XBR pixel scaler. /// </summary> /// <param name="type">The type of scaler to use.</param> /// <param name="filterRegion">The filter region, if any.</param> /// <returns> /// The rescaled image. /// </returns> public cImage ApplyScaler(XbrzScalerType type, Rect?filterRegion = null) => this.ApplyScaler(type, filterRegion?.ToRectangle()) ;
/// <summary> /// Gets the scaler information. /// </summary> /// <param name="type">The type of XBR scaler.</param> /// <returns></returns> /// <exception cref="System.NotSupportedException"></exception> public static ScalerInformation GetScalerInformation(XbrzScalerType type) => XBRz_SCALERS.TryGetValue(type, out var info) ? new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2) : throw new NotSupportedException(string.Format("XBRz scaler '{0}' not supported.", type)) ;
/// <summary> /// Gets the pixel scaler info. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public static Tuple <byte, byte, XbrzFilter> GetPixelScalerInfo(XbrzScalerType type) => XBRz_SCALERS.TryGetValue(type, out var info) ? info : throw new NotSupportedException(string.Format("XBRz scaler '{0}' not supported.", type)) ;