Package com.aowagie.text.pdf.codec
Class PngImage
- java.lang.Object
-
- com.aowagie.text.pdf.codec.PngImage
-
public class PngImage extends java.lang.Object
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 Modifier and Type Class Description private static class
PngImage.NewByteArrayOutputStream
-
Field Summary
Fields Modifier and Type Field Description private PdfDictionary
additional
private int
bitDepth
private int
bytesPerPixel
private static java.lang.String
cHRM
A PNG marker.private byte[]
colorTable
private int
colorType
private int
compressionMethod
private java.io.DataInputStream
dataStream
private int
dpiX
private int
dpiY
private int
filterMethod
private static java.lang.String
gAMA
A PNG marker.private float
gamma
private boolean
genBWMask
private boolean
hasCHRM
private int
height
private java.awt.color.ICC_Profile
icc_profile
private static java.lang.String
iCCP
A PNG marker.private PngImage.NewByteArrayOutputStream
idat
private static java.lang.String
IDAT
A PNG marker.private static java.lang.String
IEND
A PNG marker.private static java.lang.String
IHDR
A PNG marker.private byte[]
image
private int
inputBands
private PdfName
intent
private static PdfName[]
intents
private int
interlaceMethod
private java.io.InputStream
is
private boolean
palShades
private static java.lang.String
pHYs
A PNG marker.private static java.lang.String
PLTE
A PNG marker.private static int
PNG_FILTER_AVERAGE
private static int
PNG_FILTER_NONE
private static int
PNG_FILTER_PAETH
private static int
PNG_FILTER_SUB
private static int
PNG_FILTER_UP
static int[]
PNGID
Some PNG specific values.private byte[]
smask
private static java.lang.String
sRGB
A PNG marker.private byte[]
trans
private int
transBlue
private static int
TRANSFERSIZE
private int
transGreen
private int
transRedGray
private static java.lang.String
tRNS
A PNG marker.private int
width
private float
xB
private float
xG
private float
xR
private float
xW
private float
XYRatio
private float
yB
private float
yG
private float
yR
private float
yW
-
Constructor Summary
Constructors Modifier Constructor Description private
PngImage(java.io.InputStream is)
Creates a new instance of PngImage
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
checkMarker(java.lang.String s)
private static void
decodeAverageFilter(byte[] curr, byte[] prev, int count, int bpp)
private void
decodeIdat()
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
getColorspace()
private Image
getImage()
static Image
getImage(byte[] data)
Reads a PNG from a byte array.private static Image
getImage(java.io.InputStream is)
Reads a PNG from a stream.static Image
getImage(java.net.URL url)
Reads a PNG from an url.private static int
getInt(java.io.InputStream is)
Gets anint
from anInputStream
.private int[]
getPixel(byte[] curr)
private static java.lang.String
getString(java.io.InputStream is)
Gets aString
from anInputStream
.private static int
getWord(java.io.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 Detail
-
PNGID
public static final int[] PNGID
Some PNG specific values.
-
IHDR
private static final java.lang.String IHDR
A PNG marker.- See Also:
- Constant Field Values
-
PLTE
private static final java.lang.String PLTE
A PNG marker.- See Also:
- Constant Field Values
-
IDAT
private static final java.lang.String IDAT
A PNG marker.- See Also:
- Constant Field Values
-
IEND
private static final java.lang.String IEND
A PNG marker.- See Also:
- Constant Field Values
-
tRNS
private static final java.lang.String tRNS
A PNG marker.- See Also:
- Constant Field Values
-
pHYs
private static final java.lang.String pHYs
A PNG marker.- See Also:
- Constant Field Values
-
gAMA
private static final java.lang.String gAMA
A PNG marker.- See Also:
- Constant Field Values
-
cHRM
private static final java.lang.String cHRM
A PNG marker.- See Also:
- Constant Field Values
-
sRGB
private static final java.lang.String sRGB
A PNG marker.- See Also:
- Constant Field Values
-
iCCP
private static final java.lang.String iCCP
A PNG marker.- See Also:
- Constant Field Values
-
TRANSFERSIZE
private static final int TRANSFERSIZE
- See Also:
- Constant Field Values
-
PNG_FILTER_NONE
private static final int PNG_FILTER_NONE
- See Also:
- Constant Field Values
-
PNG_FILTER_SUB
private static final int PNG_FILTER_SUB
- See Also:
- Constant Field Values
-
PNG_FILTER_UP
private static final int PNG_FILTER_UP
- See Also:
- Constant Field Values
-
PNG_FILTER_AVERAGE
private static final int PNG_FILTER_AVERAGE
- See Also:
- Constant Field Values
-
PNG_FILTER_PAETH
private static final int PNG_FILTER_PAETH
- See Also:
- Constant Field Values
-
intents
private static final PdfName[] intents
-
is
private final java.io.InputStream is
-
dataStream
private java.io.DataInputStream 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
private final PdfDictionary additional
-
image
private byte[] image
-
smask
private byte[] smask
-
trans
private byte[] trans
-
idat
private final PngImage.NewByteArrayOutputStream 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
private PdfName intent
-
icc_profile
private java.awt.color.ICC_Profile icc_profile
-
-
Method Detail
-
getImage
public static Image getImage(java.net.URL url) throws java.io.IOException
Reads a PNG from an url.- Parameters:
url
- the url- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
getImage
private static Image getImage(java.io.InputStream is) throws java.io.IOException
Reads a PNG from a stream.- Parameters:
is
- the stream- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
getImage
public static Image getImage(byte[] data) throws java.io.IOException
Reads a PNG from a byte array.- Parameters:
data
- the byte array- Returns:
- the image
- Throws:
java.io.IOException
- on error
-
checkMarker
private boolean checkMarker(java.lang.String s)
-
readPng
private void readPng() throws java.io.IOException
- Throws:
java.io.IOException
-
getColorspace
private PdfObject getColorspace()
-
getImage
private Image getImage() throws java.io.IOException
- Throws:
java.io.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
private static final int getInt(java.io.InputStream is) throws java.io.IOException
Gets anint
from anInputStream
.- Parameters:
is
- anInputStream
- Returns:
- the value of an
int
- Throws:
java.io.IOException
-
getWord
private static final int getWord(java.io.InputStream is) throws java.io.IOException
Gets aword
from anInputStream
.- Parameters:
is
- anInputStream
- Returns:
- the value of an
int
- Throws:
java.io.IOException
-
getString
private static final java.lang.String getString(java.io.InputStream is) throws java.io.IOException
Gets aString
from anInputStream
.- Parameters:
is
- anInputStream
- Returns:
- the value of an
int
- Throws:
java.io.IOException
-
-