Package com.aowagie.text.pdf.codec
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 PdfDictionary
private int
private int
private static final String
A PNG marker.private byte[]
private int
private int
private DataInputStream
private int
private int
private int
private static final String
A PNG marker.private float
private boolean
private boolean
private int
private ICC_Profile
private static final String
A PNG marker.private final PngImage.NewByteArrayOutputStream
private static final String
A PNG marker.private static final String
A PNG marker.private static final String
A PNG marker.private byte[]
private int
private PdfName
private static final PdfName[]
private int
private final InputStream
private boolean
private static final String
A PNG marker.private static final String
A PNG marker.private static final int
private static final int
private static final int
private static final int
private static final int
static final int[]
Some PNG specific values.private byte[]
private static final String
A PNG marker.private byte[]
private int
private static final int
private int
private int
private static final String
A PNG marker.private int
private float
private float
private float
private float
private float
private float
private float
private float
private float
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
PngImage
(InputStream is) Creates a new instance of PngImage -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private static void
decodeAverageFilter
(byte[] curr, byte[] prev, int count, int bpp) private void
private static void
decodePaethFilter
(byte[] curr, byte[] prev, int count, int bpp) private void
decodePass
(int xOffset, int yOffset, int xStep, int yStep, int passWidth, int passHeight) private static void
decodeSubFilter
(byte[] curr, int count, int bpp) private static void
decodeUpFilter
(byte[] curr, byte[] prev, int count) private PdfObject
private Image
getImage()
static Image
getImage
(byte[] data) Reads a PNG from a byte array.private static Image
getImage
(InputStream is) Reads a PNG from a stream.static Image
Reads a PNG from an url.private static final int
getInt
(InputStream is) Gets anint
from anInputStream
.private int[]
getPixel
(byte[] curr) private static final String
getString
(InputStream is) Gets aString
from anInputStream
.private static final int
getWord
(InputStream is) Gets aword
from anInputStream
.private static int
paethPredictor
(int a, int b, int c) private void
processPixels
(byte[] curr, int xOffset, int step, int y, int width) private void
readPng()
private static void
setPixel
(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
A PNG marker.- See Also:
-
PLTE
A PNG marker.- See Also:
-
IDAT
A PNG marker.- See Also:
-
IEND
A PNG marker.- See Also:
-
tRNS
A PNG marker.- See Also:
-
pHYs
A PNG marker.- See Also:
-
gAMA
A PNG marker.- See Also:
-
cHRM
A PNG marker.- See Also:
-
sRGB
A PNG marker.- See Also:
-
iCCP
A PNG marker.- See Also:
-
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 anint
from anInputStream
.- Parameters:
is
- anInputStream
- Returns:
- the value of an
int
- Throws:
IOException
-
getWord
Gets aword
from anInputStream
.- Parameters:
is
- anInputStream
- Returns:
- the value of an
int
- Throws:
IOException
-
getString
Gets aString
from anInputStream
.- Parameters:
is
- anInputStream
- Returns:
- the value of an
int
- Throws:
IOException
-