AForge.Imaging.ColorReduction.ColorImageQuantizer.ReduceColors C# (CSharp) Method

ReduceColors() public method

Create an image with reduced number of colors using the specified palette.

See ReduceColors(UnmanagedImage, Color[]) for details.

public ReduceColors ( Bitmap image, Color palette ) : Bitmap
image System.Drawing.Bitmap Source image to process.
palette Color Target color palette. Must contatin 2-256 colors.
return System.Drawing.Bitmap
        public Bitmap ReduceColors( Bitmap image, Color[] palette )
        {
            BitmapData data = image.LockBits( new Rectangle( 0, 0, image.Width, image.Height ),
                ImageLockMode.ReadOnly, image.PixelFormat );

            try
            {
                return ReduceColors( new UnmanagedImage( data ), palette );
            }
            finally
            {
                image.UnlockBits( data );
            }
        }

Same methods

ColorImageQuantizer::ReduceColors ( Bitmap image, int paletteSize ) : Bitmap
ColorImageQuantizer::ReduceColors ( UnmanagedImage image, Color palette ) : Bitmap
ColorImageQuantizer::ReduceColors ( UnmanagedImage image, int paletteSize ) : Bitmap

Usage Example

Example #1
0
 public static Bitmap MedianCut(Bitmap bmp, int intensity)
 {
     ColorImageQuantizer ciq = new ColorImageQuantizer(new MedianCutQuantizer());
     IColorQuantizer quantizer = new MedianCutQuantizer();
     Bitmap newImage = ciq.ReduceColors(bmp, intensity);
     return newImage;
 }