Class PNGImageEncoder
- java.lang.Object
-
- org.apache.batik.ext.awt.image.codec.util.ImageEncoderImpl
-
- org.apache.batik.ext.awt.image.codec.png.PNGImageEncoder
-
- All Implemented Interfaces:
ImageEncoder
public class PNGImageEncoder extends ImageEncoderImpl
An ImageEncoder for the PNG file format.- Since:
- EA4
- Version:
- $Id: PNGImageEncoder.java 1804130 2017-08-04 14:41:11Z ssteiner $
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]alphaPaletteprivate intbitDepthprivate intbitShiftprivate byte[]bluePaletteprivate intbppprivate intcolorTypeprivate booleancompressGrayprivate byte[]currRowprivate java.io.DataOutputStreamdataOutputprivate byte[][]filteredRowsprivate byte[]greenPaletteprivate intheightprivate java.awt.image.RenderedImageimageprivate booleaninterlaceprivate static byte[]magicprivate intnumBandsprivate PNGEncodeParamparamprivate static intPNG_COLOR_GRAYprivate static intPNG_COLOR_GRAY_ALPHAprivate static intPNG_COLOR_PALETTEprivate static intPNG_COLOR_RGBprivate static intPNG_COLOR_RGB_ALPHAprivate byte[]prevRowprivate byte[]redPaletteprivate booleanskipAlphaprivate static float[]srgbChromaprivate intwidth-
Fields inherited from class org.apache.batik.ext.awt.image.codec.util.ImageEncoderImpl
output
-
-
Constructor Summary
Constructors Constructor Description PNGImageEncoder(java.io.OutputStream output, PNGEncodeParam param)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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(java.awt.image.RenderedImage im)This method encodes aRenderedImageinto PNG.private voidencodePass(java.io.OutputStream os, java.awt.image.Raster ras, int xOffset, int yOffset, int xSkip, int ySkip)private voidwriteBKGD()private voidwriteCHRM()private voidwriteGAMA()private voidwriteHIST()private voidwriteICCP()private voidwriteIDAT()private voidwriteIEND()private voidwriteIHDR()private voidwriteMagic()private voidwritePHYS()private voidwritePLTE()private voidwritePrivateChunks()private voidwriteSBIT()private voidwriteSPLT()private voidwriteSRGB()private voidwriteTEXT()private voidwriteTIME()private voidwriteTRNS()private voidwriteZTXT()-
Methods inherited from class org.apache.batik.ext.awt.image.codec.util.ImageEncoderImpl
encode, getOutputStream, getParam, setParam
-
-
-
-
Field Detail
-
PNG_COLOR_GRAY
private static final int PNG_COLOR_GRAY
- See Also:
- Constant Field Values
-
PNG_COLOR_RGB
private static final int PNG_COLOR_RGB
- See Also:
- Constant Field Values
-
PNG_COLOR_PALETTE
private static final int PNG_COLOR_PALETTE
- See Also:
- Constant Field Values
-
PNG_COLOR_GRAY_ALPHA
private static final int PNG_COLOR_GRAY_ALPHA
- See Also:
- Constant Field Values
-
PNG_COLOR_RGB_ALPHA
private static final int PNG_COLOR_RGB_ALPHA
- See Also:
- Constant Field Values
-
magic
private static final byte[] magic
-
param
private PNGEncodeParam param
-
image
private java.awt.image.RenderedImage 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
private java.io.DataOutputStream dataOutput
-
prevRow
private byte[] prevRow
-
currRow
private byte[] currRow
-
filteredRows
private byte[][] filteredRows
-
srgbChroma
private static final float[] srgbChroma
-
-
Constructor Detail
-
PNGImageEncoder
public PNGImageEncoder(java.io.OutputStream output, PNGEncodeParam param)
-
-
Method Detail
-
writeMagic
private void writeMagic() throws java.io.IOException- Throws:
java.io.IOException
-
writeIHDR
private void writeIHDR() throws java.io.IOException- Throws:
java.io.IOException
-
clamp
private static int clamp(int val, int maxValue)
-
encodePass
private void encodePass(java.io.OutputStream os, java.awt.image.Raster ras, int xOffset, int yOffset, int xSkip, int ySkip) throws java.io.IOException- Throws:
java.io.IOException
-
writeIDAT
private void writeIDAT() throws java.io.IOException- Throws:
java.io.IOException
-
writeIEND
private void writeIEND() throws java.io.IOException- Throws:
java.io.IOException
-
writeCHRM
private void writeCHRM() throws java.io.IOException- Throws:
java.io.IOException
-
writeGAMA
private void writeGAMA() throws java.io.IOException- Throws:
java.io.IOException
-
writeICCP
private void writeICCP() throws java.io.IOException- Throws:
java.io.IOException
-
writeSBIT
private void writeSBIT() throws java.io.IOException- Throws:
java.io.IOException
-
writeSRGB
private void writeSRGB() throws java.io.IOException- Throws:
java.io.IOException
-
writePLTE
private void writePLTE() throws java.io.IOException- Throws:
java.io.IOException
-
writeBKGD
private void writeBKGD() throws java.io.IOException- Throws:
java.io.IOException
-
writeHIST
private void writeHIST() throws java.io.IOException- Throws:
java.io.IOException
-
writeTRNS
private void writeTRNS() throws java.io.IOException- Throws:
java.io.IOException
-
writePHYS
private void writePHYS() throws java.io.IOException- Throws:
java.io.IOException
-
writeSPLT
private void writeSPLT() throws java.io.IOException- Throws:
java.io.IOException
-
writeTIME
private void writeTIME() throws java.io.IOException- Throws:
java.io.IOException
-
writeTEXT
private void writeTEXT() throws java.io.IOException- Throws:
java.io.IOException
-
writeZTXT
private void writeZTXT() throws java.io.IOException- Throws:
java.io.IOException
-
writePrivateChunks
private void writePrivateChunks() throws java.io.IOException- Throws:
java.io.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
public void encode(java.awt.image.RenderedImage im) throws java.io.IOExceptionThis 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:
java.io.IOException
-
-