Esempio n. 1
0
        /// <summary>
        /// Applies Grayscale toning to the image.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="mode">The formula to apply to perform the operation.</param>
        /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
        public static Image <TColor, TPacked> Grayscale <TColor, TPacked>(this Image <TColor, TPacked> source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709)
            where TColor : struct, IPackedPixel <TPacked>
            where TPacked : struct, IEquatable <TPacked>
        {
            IImageFilteringProcessor <TColor, TPacked> processor = mode == GrayscaleMode.Bt709
                ? (IImageFilteringProcessor <TColor, TPacked>) new GrayscaleBt709Processor <TColor, TPacked>()
                : new GrayscaleBt601Processor <TColor, TPacked>();

            return(source.Process(rectangle, processor));
        }
 /// <summary>
 /// Applies the processor to the image.
 /// <remarks>This method does not resize the target image.</remarks>
 /// </summary>
 /// <typeparam name="TColor">The pixel format.</typeparam>
 /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="sourceRectangle">
 /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
 /// </param>
 /// <param name="processor">The processors to apply to the image.</param>
 /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
 internal static Image <TColor, TPacked> Process <TColor, TPacked>(this Image <TColor, TPacked> source, Rectangle sourceRectangle, IImageFilteringProcessor <TColor, TPacked> processor)
     where TColor : struct, IPackedPixel <TPacked>
     where TPacked : struct
 {
     return(PerformAction(source, (sourceImage) => processor.Apply(sourceImage, sourceRectangle)));
 }
 /// <summary>
 /// Applies the processor to the image.
 /// <remarks>This method does not resize the target image.</remarks>
 /// </summary>
 /// <typeparam name="TColor">The pixel format.</typeparam>
 /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="processor">The processor to apply to the image.</param>
 /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
 internal static Image <TColor, TPacked> Process <TColor, TPacked>(this Image <TColor, TPacked> source, IImageFilteringProcessor <TColor, TPacked> processor)
     where TColor : struct, IPackedPixel <TPacked>
     where TPacked : struct
 {
     return(Process(source, source.Bounds, processor));
 }