public NqScaler(NqScalerType type, NqMode mode) { var info = cImage.GetPixelScalerInfo(type); this._type = type; this._mode = mode; this._scaleFactorX = info.Item1; this._scaleFactorY = info.Item2; }
public NqScaler(NqScalerType type, NqMode mode) { var info = cImage.GetPixelScalerInfo(type); this._type = type; this._mode = mode; this.ScaleFactorX = info.Item1; this.ScaleFactorY = info.Item2; }
/// <summary> /// Gets the scaler information. /// </summary> /// <param name="type">The type of nq scaler.</param> /// <returns></returns> /// <exception cref="System.NotSupportedException"></exception> public static ScalerInformation GetScalerInformation(NqScalerType type) { Tuple <byte, byte, NqKernel> info; if (NQ_SCALERS.TryGetValue(type, out info)) { return(new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2)); } throw new NotSupportedException(string.Format("NQ 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, NqKernel> GetPixelScalerInfo(NqScalerType type) { Tuple <byte, byte, NqKernel> info; if (NQ_SCALERS.TryGetValue(type, out info)) { return(info); } throw new NotSupportedException(string.Format("NQ scaler '{0}' not supported.", type)); }
/// <summary> /// Applies the NQ pixel scaler. /// </summary> /// <param name="type">The type of scaler to use.</param> /// <param name="mode">The mode.</param> /// <param name="filterRegion">The filter region, if any.</param> /// <returns> /// The rescaled image. /// </returns> public cImage ApplyScaler(NqScalerType type, NqMode mode, Rectangle?filterRegion = null) { var info = GetPixelScalerInfo(type); var scaler = GetPixelScalerInfo(mode); var scaleX = info.Item1; var scaleY = info.Item2; var kernel = info.Item3; return(this._RunLoop(filterRegion, scaleX, scaleY, worker => scaler(worker, scaleX, scaleY, kernel))); }
/// <summary> /// Applies the NQ pixel scaler. /// </summary> /// <param name="type">The type of scaler to use.</param> /// <param name="mode">The mode.</param> /// <param name="filterRegion">The filter region, if any.</param> /// <returns> /// The rescaled image. /// </returns> public cImage ApplyScaler(NqScalerType type, NqMode mode, Rectangle? filterRegion = null) { var info = GetPixelScalerInfo(type); var scaler = GetPixelScalerInfo(mode); var scaleX = info.Item1; var scaleY = info.Item2; var kernel = info.Item3; return (this._RunLoop(filterRegion, scaleX, scaleY, worker => scaler(worker, scaleX, scaleY, kernel))); }
/// <summary> /// Gets the scaler information. /// </summary> /// <param name="type">The type of nq scaler.</param> /// <returns></returns> /// <exception cref="System.NotSupportedException"></exception> public static ScalerInformation GetScalerInformation(NqScalerType type) { Tuple<byte, byte, NqKernel> info; if (NQ_SCALERS.TryGetValue(type, out info)) return (new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2)); throw new NotSupportedException(string.Format("NQ 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, NqKernel> GetPixelScalerInfo(NqScalerType type) { Tuple<byte, byte, NqKernel> info; if (NQ_SCALERS.TryGetValue(type, out info)) return (info); throw new NotSupportedException(string.Format("NQ scaler '{0}' not supported.", type)); }
/// <summary> /// Gets the scaler information. /// </summary> /// <param name="type">The type of nq scaler.</param> /// <returns></returns> /// <exception cref="System.NotSupportedException"></exception> public static ScalerInformation GetScalerInformation(NqScalerType type) => NQ_SCALERS.TryGetValue(type, out var info) ? new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2) : throw new NotSupportedException(string.Format("NQ 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, NqKernel> GetPixelScalerInfo(NqScalerType type) => NQ_SCALERS.TryGetValue(type, out var info) ? info : throw new NotSupportedException(string.Format("NQ scaler '{0}' not supported.", type)) ;
/// <summary> /// Applies the NQ pixel scaler. /// </summary> /// <param name="type">The type of scaler to use.</param> /// <param name="mode">The mode.</param> /// <param name="filterRegion">The filter region, if any.</param> /// <returns> /// The rescaled image. /// </returns> public cImage ApplyScaler(NqScalerType type, NqMode mode, Rect?filterRegion = null) => this.ApplyScaler(type, mode, filterRegion?.ToRectangle()) ;