Exemplo n.º 1
0
 /// <summary>
 /// Modifies channel balance using memory-friendly Pipeline API
 /// </summary>
 private static void ChannelBalanceMemoryFriendly()
 {
     using (var reader = ImageReader.Create("../../../../_Input/Chicago.jpg"))
         using (var channelBalance = new ChannelBalance()
         {
             // Pixel format specifies the order of channels
             // Example: Format24bppRgb - [Blue]|[Green]|[Red]
             // http://www.graphicsmill.com/docs/gm/accessing-pixel-data.htm#PixelsInMemory
             Addends = new float[] { 0.0f, 0.0f, 0.3f }
         })
             using (var writer = ImageWriter.Create("../../../../_Output/ChannelBalanceMemoryFriendly.jpg"))
             {
                 Pipeline.Run(reader + channelBalance + writer);
             }
 }
Exemplo n.º 2
0
        public static void ProcessImage(IProcessorItem item)
        {
            using (ImageReader reader = ImageReader.Create(item.Source))
            using (var contrast = new Contrast(item.Correction.Contrast))
            using (var levels = new Levels(item.Correction.Black, item.Correction.White, item.Correction.Shadow, item.Correction.Midpoint, item.Correction.Highlight, HistogramMode.Luminosity))
            using (var color = new ChannelBalance())
            using (var rotate = new Rotate(item.Correction.Rotate))
            using (var saturation = new AdjustHsl(0f, item.Correction.Saturation, 0f))
            using (var writer = new JpegWriter(Path.ChangeExtension(item.Destination, "jpg"), 99))
            {
                color.Addends = new float[3]
                {
                    item.Correction.Blue,
                    item.Correction.Green,
                    item.Correction.Red
                };
                color.Multipliers = new float[3]
                {
                    1f,
                    1f,
                    1f
                };

                writer.UseSubsampling = false;

                Pipeline.Run(reader + contrast + levels + color + rotate + saturation + writer);
            }
        }