Ejemplo n.º 1
0
        /// <summary>
        /// Applies filter to bitmap.
        /// </summary>
        /// <param name="image">Bitmap</param>
        /// <returns>Bitmap</returns>
        public Bitmap Apply(Bitmap image)
        {
            Bitmap clone = (Bitmap)image.Clone();

            flip.Apply(clone);
            return(clone);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Apply the current text settings to the values
        /// </summary>
        /// <param name="values">values array to be used</param>
        /// <returns>Array of strings from the values using the current settings</returns>
        public string[] Apply(byte[,] values)
        {
            if (values == null)
            {
                return(null);
            }

            // only apply brightness and contrast if necessary
            if (Brightness != 0 || Contrast != 0)
            {
                BrightnessContrast filter = new BrightnessContrast(IsBlackTextOnWhite ? Brightness : -Brightness,
                                                                   IsBlackTextOnWhite ? Contrast : -Contrast);

                values = filter.Apply(values);
            }

            if (Stretch)
            {
                Stretch filter = new Stretch();
                values = filter.Apply(values);
            }

            if (Levels.Minimum != 0 || Levels.Maximum != 255 || Levels.Median != 0.5f)
            {
                //values = AscgenConverter.ApplyLevels(values, Levels.Minimum, Levels.Maximum, Levels.Median);

                Levels filter = new Levels(Levels.Minimum, Levels.Maximum, Levels.Median);
                values = filter.Apply(values);
            }

            if (Sharpen)
            {
                values = AsciiConverter.SharpenValues(values);
            }

            if (Unsharp)
            {
                values = AsciiConverter.UnsharpMaskValues(values, 3);
            }

            if (FlipHorizontally || FlipVertically)
            {
                Flip filter = new Flip(FlipHorizontally, FlipVertically);
                values = filter.Apply(values);
            }

            return(_ValuesToText.Apply(values));
        }