Class PNGImageEncoder
java.lang.Object
org.apache.xmlgraphics.image.codec.util.ImageEncoderImpl
org.apache.xmlgraphics.image.codec.png.PNGImageEncoder
- All Implemented Interfaces:
ImageEncoder
An ImageEncoder for the PNG file format.
- Since:
- EA4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]private intprivate intprivate byte[]private intprivate intprivate booleanprivate byte[]private DataOutputStreamprivate byte[][]private byte[]private intprivate RenderedImageprivate booleanprivate static final byte[]private intprivate PNGEncodeParamprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate byte[]private byte[]private booleanprivate static final float[]private intFields inherited from class org.apache.xmlgraphics.image.codec.util.ImageEncoderImpl
output -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intclamp(int val, int maxValue) private PNGEncodeParam.GraycreateGrayParam(byte[] redPalette, byte[] greenPalette, byte[] bluePalette, byte[] alphaPalette) Analyzes a set of palettes and determines if it can be expressed as a standard set of gray values, with zero or one values being fully transparent and the rest being fully opaque.voidencode(RenderedImage im) This method encodes aRenderedImageinto PNG.private voidencodePass(OutputStream os, Raster ras, int xOffset, int yOffset, int xSkip, int ySkip) private voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidMethods inherited from class org.apache.xmlgraphics.image.codec.util.ImageEncoderImpl
encode, getOutputStream, getParam, setParam
-
Field Details
-
PNG_COLOR_GRAY
private static final int PNG_COLOR_GRAY- See Also:
-
PNG_COLOR_RGB
private static final int PNG_COLOR_RGB- See Also:
-
PNG_COLOR_PALETTE
private static final int PNG_COLOR_PALETTE- See Also:
-
PNG_COLOR_GRAY_ALPHA
private static final int PNG_COLOR_GRAY_ALPHA- See Also:
-
PNG_COLOR_RGB_ALPHA
private static final int PNG_COLOR_RGB_ALPHA- See Also:
-
MAGIC
private static final byte[] MAGIC -
param
-
image
-
width
private int width -
height
private int height -
bitDepth
private int bitDepth -
bitShift
private int bitShift -
numBands
private int numBands -
colorType
private int colorType -
bpp
private int bpp -
skipAlpha
private boolean skipAlpha -
compressGray
private boolean compressGray -
interlace
private boolean interlace -
redPalette
private byte[] redPalette -
greenPalette
private byte[] greenPalette -
bluePalette
private byte[] bluePalette -
alphaPalette
private byte[] alphaPalette -
dataOutput
-
prevRow
private byte[] prevRow -
currRow
private byte[] currRow -
filteredRows
private byte[][] filteredRows -
SRGB_CHROMA
private static final float[] SRGB_CHROMA
-
-
Constructor Details
-
PNGImageEncoder
-
-
Method Details
-
writeMagic
- Throws:
IOException
-
writeIHDR
- Throws:
IOException
-
clamp
private static int clamp(int val, int maxValue) -
encodePass
private void encodePass(OutputStream os, Raster ras, int xOffset, int yOffset, int xSkip, int ySkip) throws IOException - Throws:
IOException
-
writeIDAT
- Throws:
IOException
-
writeIEND
- Throws:
IOException
-
writeCHRM
- Throws:
IOException
-
writeGAMA
- Throws:
IOException
-
writeICCP
- Throws:
IOException
-
writeSBIT
- Throws:
IOException
-
writeSRGB
- Throws:
IOException
-
writePLTE
- Throws:
IOException
-
writeBKGD
- Throws:
IOException
-
writeHIST
- Throws:
IOException
-
writeTRNS
- Throws:
IOException
-
writePHYS
- Throws:
IOException
-
writeSPLT
- Throws:
IOException
-
writeTIME
- Throws:
IOException
-
writeTEXT
- Throws:
IOException
-
writeZTXT
- Throws:
IOException
-
writePrivateChunks
- Throws:
IOException
-
createGrayParam
private PNGEncodeParam.Gray createGrayParam(byte[] redPalette, byte[] greenPalette, byte[] bluePalette, byte[] alphaPalette) Analyzes a set of palettes and determines if it can be expressed as a standard set of gray values, with zero or one values being fully transparent and the rest being fully opaque. If it is possible to express the data thusly, the method returns a suitable instance of PNGEncodeParam.Gray; otherwise it returns null. -
encode
This method encodes aRenderedImageinto PNG. The stream into which the PNG is dumped is not closed at the end of the operation, this should be done if needed by the caller of this method.- Specified by:
encodein interfaceImageEncoder- Specified by:
encodein classImageEncoderImpl- Throws:
IOException
-