Esempio n. 1
0
        public PixelScaler(PixelScalerType type)
        {
            var info = cImage.GetPixelScalerInfo(type);

            this._type         = type;
            this._scaleFactorX = info.Item1;
            this._scaleFactorY = info.Item2;
        }
        /// <summary>
        /// Applies the pixel scaler without any parameters.
        /// </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(PixelScalerType type, Rectangle?filterRegion = null)
        {
            var info   = GetPixelScalerInfo(type);
            var scaleX = info.Item1;
            var scaleY = info.Item2;
            var scaler = info.Item3;

            return(this._RunLoop(filterRegion, scaleX, scaleY, w => scaler(w)));
        }
        /// <summary>
        /// Gets the scaler information.
        /// </summary>
        /// <param name="type">The type of pixel scaler.</param>
        /// <returns></returns>
        /// <exception cref="System.NotSupportedException"></exception>
        public static ScalerInformation GetScalerInformation(PixelScalerType type)
        {
            Tuple <byte, byte, ParameterlessPixelScaler> info;

            if (PIXEL_SCALERS.TryGetValue(type, out info))
            {
                return(new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2));
            }
            throw new NotSupportedException(string.Format("Parameterless scaler '{0}' not supported.", type));
        }
Esempio n. 4
0
 public PixelScaler(PixelScalerType type) {
   var info = cImage.GetPixelScalerInfo(type);
   this._type = type;
   this._scaleFactorX = info.Item1;
   this._scaleFactorY = info.Item2;
 }
 /// <summary>
 /// Gets the scaler information.
 /// </summary>
 /// <param name="type">The type of pixel scaler.</param>
 /// <returns></returns>
 /// <exception cref="System.NotSupportedException"></exception>
 public static ScalerInformation GetScalerInformation(PixelScalerType type)
 => PIXEL_SCALERS.TryGetValue(type, out var info)
 ? new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2)
 : throw new NotSupportedException(string.Format("Parameterless scaler '{0}' not supported.", type))
 ;
 /// <summary>
 /// Gets the parameterless pixel scaler info.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns></returns>
 public static Tuple <byte, byte, ParameterlessPixelScaler> GetPixelScalerInfo(PixelScalerType type)
 => PIXEL_SCALERS.TryGetValue(type, out var info)
 ? info
 : throw new NotSupportedException(string.Format("Parameterless scaler '{0}' not supported.", type))
 ;
 /// <summary>
 /// Applies the pixel scaler without any parameters.
 /// </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(PixelScalerType type, Rect?filterRegion = null)
 => this.ApplyScaler(type, filterRegion?.ToRectangle())
 ;
    /// <summary>
    /// Applies the pixel scaler without any parameters.
    /// </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(PixelScalerType type, Rectangle? filterRegion = null) {
      var info = GetPixelScalerInfo(type);
      var scaleX = info.Item1;
      var scaleY = info.Item2;
      var scaler = info.Item3;

      return (this._RunLoop(filterRegion, scaleX, scaleY, w => scaler(w)));
    }
 /// <summary>
 /// Gets the scaler information.
 /// </summary>
 /// <param name="type">The type of pixel scaler.</param>
 /// <returns></returns>
 /// <exception cref="System.NotSupportedException"></exception>
 public static ScalerInformation GetScalerInformation(PixelScalerType type) {
   Tuple<byte, byte, ParameterlessPixelScaler> info;
   if (PIXEL_SCALERS.TryGetValue(type, out info))
     return (new ScalerInformation(ReflectionUtils.GetDisplayNameForEnumValue(type), ReflectionUtils.GetDescriptionForEnumValue(type), info.Item1, info.Item2));
   throw new NotSupportedException(string.Format("Parameterless scaler '{0}' not supported.", type));
 }
 /// <summary>
 /// Gets the parameterless pixel scaler info.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns></returns>
 internal static Tuple<byte, byte, ParameterlessPixelScaler> GetPixelScalerInfo(PixelScalerType type) {
   Tuple<byte, byte, ParameterlessPixelScaler> info;
   if (PIXEL_SCALERS.TryGetValue(type, out info))
     return (info);
   throw new NotSupportedException(string.Format("Parameterless scaler '{0}' not supported.", type));
 }
        /// <summary>
        /// Gets the parameterless pixel scaler info.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        internal static Tuple <byte, byte, ParameterlessPixelScaler> GetPixelScalerInfo(PixelScalerType type)
        {
            Tuple <byte, byte, ParameterlessPixelScaler> info;

            if (PIXEL_SCALERS.TryGetValue(type, out info))
            {
                return(info);
            }
            throw new NotSupportedException(string.Format("Parameterless scaler '{0}' not supported.", type));
        }