Class PngImage
java.lang.Object
com.aowagie.text.pdf.codec.PngImage
Reads a PNG image. All types of PNG can be read.
It is based in part in the JAI codec.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PdfDictionaryprivate intprivate intprivate static final StringA PNG marker.private byte[]private intprivate intprivate DataInputStreamprivate intprivate intprivate intprivate static final StringA PNG marker.private floatprivate booleanprivate booleanprivate intprivate ICC_Profileprivate static final StringA PNG marker.private final PngImage.NewByteArrayOutputStreamprivate static final StringA PNG marker.private static final StringA PNG marker.private static final StringA PNG marker.private byte[]private intprivate PdfNameprivate static final PdfName[]private intprivate final InputStreamprivate booleanprivate static final StringA PNG marker.private static final StringA PNG marker.private static final intprivate static final intprivate static final intprivate static final intprivate static final intstatic final int[]Some PNG specific values.private byte[]private static final StringA PNG marker.private byte[]private intprivate static final intprivate intprivate intprivate static final StringA PNG marker.private intprivate floatprivate floatprivate floatprivate floatprivate floatprivate floatprivate floatprivate floatprivate float -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePngImage(InputStream is) Creates a new instance of PngImage -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanprivate static voiddecodeAverageFilter(byte[] curr, byte[] prev, int count, int bpp) private voidprivate static voiddecodePaethFilter(byte[] curr, byte[] prev, int count, int bpp) private voiddecodePass(int xOffset, int yOffset, int xStep, int yStep, int passWidth, int passHeight) private static voiddecodeSubFilter(byte[] curr, int count, int bpp) private static voiddecodeUpFilter(byte[] curr, byte[] prev, int count) private PdfObjectprivate ImagegetImage()static ImagegetImage(byte[] data) Reads a PNG from a byte array.private static ImagegetImage(InputStream is) Reads a PNG from a stream.static ImageReads a PNG from an url.private static final intgetInt(InputStream is) Gets anintfrom anInputStream.private int[]getPixel(byte[] curr) private static final StringgetString(InputStream is) Gets aStringfrom anInputStream.private static final intgetWord(InputStream is) Gets awordfrom anInputStream.private static intpaethPredictor(int a, int b, int c) private voidprocessPixels(byte[] curr, int xOffset, int step, int y, int width) private voidreadPng()private static voidsetPixel(byte[] image, int[] data, int offset, int size, int x, int y, int bitDepth, int bytesPerRow)
-
Field Details
-
PNGID
public static final int[] PNGIDSome PNG specific values. -
IHDR
-
PLTE
-
IDAT
-
IEND
-
tRNS
-
pHYs
-
gAMA
-
cHRM
-
sRGB
-
iCCP
-
TRANSFERSIZE
private static final int TRANSFERSIZE- See Also:
-
PNG_FILTER_NONE
private static final int PNG_FILTER_NONE- See Also:
-
PNG_FILTER_SUB
private static final int PNG_FILTER_SUB- See Also:
-
PNG_FILTER_UP
private static final int PNG_FILTER_UP- See Also:
-
PNG_FILTER_AVERAGE
private static final int PNG_FILTER_AVERAGE- See Also:
-
PNG_FILTER_PAETH
private static final int PNG_FILTER_PAETH- See Also:
-
intents
-
is
-
dataStream
-
width
private int width -
height
private int height -
bitDepth
private int bitDepth -
colorType
private int colorType -
compressionMethod
private int compressionMethod -
filterMethod
private int filterMethod -
interlaceMethod
private int interlaceMethod -
additional
-
image
private byte[] image -
smask
private byte[] smask -
trans
private byte[] trans -
idat
-
dpiX
private int dpiX -
dpiY
private int dpiY -
XYRatio
private float XYRatio -
genBWMask
private boolean genBWMask -
palShades
private boolean palShades -
transRedGray
private int transRedGray -
transGreen
private int transGreen -
transBlue
private int transBlue -
inputBands
private int inputBands -
bytesPerPixel
private int bytesPerPixel -
colorTable
private byte[] colorTable -
gamma
private float gamma -
hasCHRM
private boolean hasCHRM -
xW
private float xW -
yW
private float yW -
xR
private float xR -
yR
private float yR -
xG
private float xG -
yG
private float yG -
xB
private float xB -
yB
private float yB -
intent
-
icc_profile
-
-
Constructor Details
-
PngImage
Creates a new instance of PngImage
-
-
Method Details
-
getImage
Reads a PNG from an url.- Parameters:
url- the url- Returns:
- the image
- Throws:
IOException- on error
-
getImage
Reads a PNG from a stream.- Parameters:
is- the stream- Returns:
- the image
- Throws:
IOException- on error
-
getImage
Reads a PNG from a byte array.- Parameters:
data- the byte array- Returns:
- the image
- Throws:
IOException- on error
-
checkMarker
-
readPng
- Throws:
IOException
-
getColorspace
-
getImage
- Throws:
IOException
-
decodeIdat
private void decodeIdat() -
decodePass
private void decodePass(int xOffset, int yOffset, int xStep, int yStep, int passWidth, int passHeight) -
processPixels
private void processPixels(byte[] curr, int xOffset, int step, int y, int width) -
setPixel
private static void setPixel(byte[] image, int[] data, int offset, int size, int x, int y, int bitDepth, int bytesPerRow) -
getPixel
private int[] getPixel(byte[] curr) -
decodeSubFilter
private static void decodeSubFilter(byte[] curr, int count, int bpp) -
decodeUpFilter
private static void decodeUpFilter(byte[] curr, byte[] prev, int count) -
decodeAverageFilter
private static void decodeAverageFilter(byte[] curr, byte[] prev, int count, int bpp) -
paethPredictor
private static int paethPredictor(int a, int b, int c) -
decodePaethFilter
private static void decodePaethFilter(byte[] curr, byte[] prev, int count, int bpp) -
getInt
Gets anintfrom anInputStream.- Parameters:
is- anInputStream- Returns:
- the value of an
int - Throws:
IOException
-
getWord
Gets awordfrom anInputStream.- Parameters:
is- anInputStream- Returns:
- the value of an
int - Throws:
IOException
-
getString
Gets aStringfrom anInputStream.- Parameters:
is- anInputStream- Returns:
- the value of an
int - Throws:
IOException
-