Enum PngColorType

Enum PngColorType

Namespace: Aspose.Imaging.FileFormats.Png
Assembly: Aspose.Imaging.dll (25.7.0)

Represents the PNG image color type.

public enum PngColorType
   {
      Greyscale = 0,
      Rgb = 2,
      Indexed = 3,
      Rgba = 6
   }

Fields

Grayscale = 0

Represents the color type where each pixel is a greyscale sample.

GrayscaleWithAlpha = 4

Represents the color type where each pixel is a greyscale sample followed by an alpha sample.

IndexedColor = 3

Represents the color type where each pixel is a palette index; a PLTE chunk shall appear.

Truecolor = 2

Represents the color type where each pixel is an R,G,B triple.

TruecolorWithAlpha = 6

Represents the color type where each pixel is an R,G,B triple followed by an alpha sample.

Examples

The following example shows how to compress a PNG image, using indexed color with best fit palette

string sourceFilePath = "OriginalRings.png";
   string outputFilePath = "OriginalRingsOutput.pnG";
   using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(sourceFilePath))
   {
       image.Save(outputFilePath, new Aspose.Imaging.ImageOptions.PngOptions()
       {
           Progressive = true,
           ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.IndexedColor,
           CompressionLevel = 9,
           Palette = Aspose.Imaging.ColorPaletteHelper.GetCloseImagePalette((Aspose.Imaging.RasterImage)image, 256, Aspose.Imaging.PaletteMiningMethod.Histogram)
       });
   }
 English