public final class PngColorType
extends com.aspose.ms.System.Enum
Represents the PNG image color type.
The following example shows how to compress a PNG image, using indexed color with best fit palette
// Loads png image String sourceFilePath = "OriginalRings.png"; String outputFilePath = "OriginalRingsOutput.png"; try (com.aspose.imaging.Image image = com.aspose.imaging.Image.load(sourceFilePath)) { com.aspose.imaging.imageoptions.PngOptions options = new com.aspose.imaging.imageoptions.PngOptions(); options.setProgressive(true); // Use indexed color type options.setColorType(com.aspose.imaging.fileformats.png.PngColorType.IndexedColor); // Use maximal compression options.setCompressionLevel(9); // Get the closest 8-bit color palette which covers as many pixels as possible, so that a palettized image // is almost visually indistinguishable from a non-palletized one. options.setPalette(com.aspose.imaging.ColorPaletteHelper.getCloseImagePalette((com.aspose.imaging.RasterImage)image, 256, Aspose.Imaging.PaletteMiningMethod.Histogram)); image.save(outputFilePath, options); } // The output file size should be significantly reduced
Modifier and Type | Field and Description |
---|---|
static int |
Grayscale
Represents the color type where each pixel is a greyscale sample.
|
static int |
GrayscaleWithAlpha
Represents the color type where each pixel is a grayscale sample followed by an alpha sample.
|
static int |
IndexedColor
Represents the color type where each pixel is a palette index; a PLTE chunk shall appear.
|
static int |
Truecolor
Represents the color type where each pixel is an R,G,B triple.
|
static int |
TruecolorWithAlpha
Represents the color type where each pixel is an R,G,B triple followed by an alpha sample.
|
Clone, CloneTo, format, format, get_Caption, get_Value, getName, getName, getNames, getNames, getNames, getUnderlyingType, getUnderlyingType, getValue, getValues, getValues, getValues, isDefined, isDefined, isDefined, isDefined, parse, parse, parse, parse, register, toObject, toString
public static final int Grayscale
Represents the color type where each pixel is a greyscale sample.
public static final int Truecolor
Represents the color type where each pixel is an R,G,B triple.
public static final int IndexedColor
Represents the color type where each pixel is a palette index; a PLTE chunk shall appear.
public static final int GrayscaleWithAlpha
Represents the color type where each pixel is a grayscale sample followed by an alpha sample.
public static final int TruecolorWithAlpha
Represents the color type where each pixel is an R,G,B triple followed by an alpha sample.
Copyright (c) 2008-2022 Aspose Pty Ltd. All Rights Reserved.