예제 #1
0
 /// <summary>
 /// Initializes "portrait mode" filter.
 /// </summary>
 /// <param name="strength">Strength</param>
 public PortraitModeFilter(double strength)
 {
     _boxBlur            = new BoxBlur();
     _alphaChannelFilter = new AlphaChannelFilter();
     _merge    = new Merge(0, 0, 255);
     _strength = strength;
 }
        /// <summary>
        /// Applies a box blur to the image.
        /// </summary>
        /// <param name="source">The image this method extends.</param>
        /// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
        /// <returns>The <see cref="Image"/>.</returns>
        public static Image BoxBlur(this Image source, int radius, Rectangle rectangle, ProgressEventHandler progressHandler = null)
        {
            BoxBlur processor = new BoxBlur(radius);
            processor.OnProgress += progressHandler;

            try
            {
                return source.Process(rectangle, processor);
            }
            finally
            {
                processor.OnProgress -= progressHandler;
            }
        }