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 int
private int
private byte[]
private int
private int
private boolean
private byte[]
private DataOutputStream
private byte[][]
private byte[]
private int
private RenderedImage
private boolean
private static final byte[]
private int
private PNGEncodeParam
private static final int
private static final int
private static final int
private static final int
private static final int
private byte[]
private byte[]
private boolean
private static final float[]
private int
Fields inherited from class org.apache.xmlgraphics.image.codec.util.ImageEncoderImpl
output
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
clamp
(int val, int maxValue) 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.void
encode
(RenderedImage im) This method encodes aRenderedImage
into PNG.private void
encodePass
(OutputStream os, Raster ras, int xOffset, int yOffset, int xSkip, int ySkip) private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
private void
Methods 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 aRenderedImage
into 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:
encode
in interfaceImageEncoder
- Specified by:
encode
in classImageEncoderImpl
- Throws:
IOException
-