Exemple #1
0
        internal override Image GetQuantizedImage(ImageBuffer image, int colorCount, Pixel[] lookups, int alphaThreshold)
        {
            var result           = new Bitmap(image.Image.Width, image.Image.Height, PixelFormat.Format8bppIndexed);
            var resultBuffer     = new ImageBuffer(result);
            var paletteHistogram = new PaletteColorHistory[colorCount + 1];

            resultBuffer.UpdatePixelIndexes(IndexedPixels(image, lookups, alphaThreshold, paletteHistogram));
            result.Palette = BuildPalette(result.Palette, paletteHistogram);
            return(result);
        }
 internal override Image GetQuantizedImage(ImageBuffer image, int colorCount, int maxColors, Pixel[] lookups, int alphaThreshold)
 {
     PixelFormat pf;
     switch (maxColors)
     {
         case 256: pf = PixelFormat.Format8bppIndexed; break;
         case 16: pf = PixelFormat.Format4bppIndexed; break;
         case 2: pf = PixelFormat.Format1bppIndexed; break;
         default: throw new QuantizationException(string.Format("The target amount of colors is not supported. Requested {0} colors.", maxColors));
     }
     var result = new Bitmap(image.Image.Width, image.Image.Height, pf);
     var resultBuffer = new ImageBuffer(result);
     var paletteHistogram = new PaletteColorHistory[colorCount + 1];
     resultBuffer.UpdatePixelIndexes(indexedPixels(image, lookups, alphaThreshold, maxColors, paletteHistogram));
     result.Palette = BuildPalette(result.Palette, paletteHistogram);
     return result;
 }
Exemple #3
0
        internal override Image GetQuantizedImage(ImageBuffer image, int colorCount, int maxColors, Pixel[] lookups, int alphaThreshold)
        {
            PixelFormat pf;

            switch (maxColors)
            {
            case 256: pf = PixelFormat.Format8bppIndexed; break;

            case 16: pf = PixelFormat.Format4bppIndexed; break;

            case 2: pf = PixelFormat.Format1bppIndexed; break;

            default: throw new QuantizationException(string.Format("The target amount of colors is not supported. Requested {0} colors.", maxColors));
            }
            var result           = new Bitmap(image.Image.Width, image.Image.Height, pf);
            var resultBuffer     = new ImageBuffer(result);
            var paletteHistogram = new PaletteColorHistory[colorCount + 1];

            resultBuffer.UpdatePixelIndexes(indexedPixels(image, lookups, alphaThreshold, maxColors, paletteHistogram));
            result.Palette = BuildPalette(result.Palette, paletteHistogram);
            return(result);
        }