Package com.itextpdf.text.pdf.codec
Class PngImage
java.lang.Object
com.itextpdf.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 ClassesModifier and TypeClassDescription(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) PdfDictionary
(package private) int
(package private) int
static final String
A PNG marker.(package private) byte[]
(package private) int
(package private) int
(package private) DataInputStream
(package private) int
(package private) int
(package private) int
static final String
A PNG marker.(package private) float
(package private) boolean
(package private) boolean
(package private) int
(package private) ICC_Profile
static final String
A PNG marker.(package private) PngImage.NewByteArrayOutputStream
static final String
A PNG marker.static final String
A PNG marker.static final String
A PNG marker.(package private) byte[]
(package private) int
(package private) PdfName
private static final PdfName[]
(package private) int
(package private) InputStream
(package private) boolean
static final String
A PNG marker.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.(package private) byte[]
static final String
A PNG marker.(package private) byte[]
(package private) int
private static final int
(package private) int
(package private) int
static final String
A PNG marker.(package private) int
(package private) float
(package private) float
(package private) float
(package private) float
(package private) float
(package private) float
(package private) float
(package private) float
(package private) float
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
(package private) boolean
private static void
decodeAverageFilter
(byte[] curr, byte[] prev, int count, int bpp) (package private) void
private static void
decodePaethFilter
(byte[] curr, byte[] prev, int count, int bpp) (package 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) (package private) PdfObject
private int
(package private) Image
getImage()
static Image
getImage
(byte[] data) Reads a PNG from a byte array.static Image
getImage
(InputStream is) Reads a PNG from a stream.static Image
Reads a PNG from a file.static Image
Reads a PNG from an url.static final int
getInt
(InputStream is) Gets anint
from anInputStream
.(package private) int[]
getPixel
(byte[] curr) (package private) static int
getPixel
(byte[] image, int x, int y, int bitDepth, int bytesPerRow) static final String
getString
(InputStream is) Gets aString
from anInputStream
.static final int
getWord
(InputStream is) Gets aword
from anInputStream
.private static int
paethPredictor
(int a, int b, int c) (package private) void
processPixels
(byte[] curr, int xOffset, int step, int y, int width) (package private) void
readPng()
(package 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
InputStream is -
dataStream
DataInputStream dataStream -
width
int width -
height
int height -
bitDepth
int bitDepth -
colorType
int colorType -
compressionMethod
int compressionMethod -
filterMethod
int filterMethod -
interlaceMethod
int interlaceMethod -
additional
PdfDictionary additional -
image
byte[] image -
smask
byte[] smask -
trans
byte[] trans -
idat
-
dpiX
int dpiX -
dpiY
int dpiY -
XYRatio
float XYRatio -
genBWMask
boolean genBWMask -
palShades
boolean palShades -
transRedGray
int transRedGray -
transGreen
int transGreen -
transBlue
int transBlue -
inputBands
int inputBands -
bytesPerPixel
int bytesPerPixel -
colorTable
byte[] colorTable -
gamma
float gamma -
hasCHRM
boolean hasCHRM -
xW
float xW -
yW
float yW -
xR
float xR -
yR
float yR -
xG
float xG -
yG
float yG -
xB
float xB -
yB
float yB -
intent
PdfName intent -
icc_profile
ICC_Profile icc_profile
-
-
Constructor Details
-
PngImage
PngImage(InputStream is) 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 file.- Parameters:
file
- the file- 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
PdfObject getColorspace() -
getImage
- Throws:
IOException
-
decodeIdat
void decodeIdat() -
decodePass
void decodePass(int xOffset, int yOffset, int xStep, int yStep, int passWidth, int passHeight) -
processPixels
void processPixels(byte[] curr, int xOffset, int step, int y, int width) -
getPixel
static int getPixel(byte[] image, int x, int y, int bitDepth, int bytesPerRow) -
setPixel
static void setPixel(byte[] image, int[] data, int offset, int size, int x, int y, int bitDepth, int bytesPerRow) -
getPixel
int[] getPixel(byte[] curr) -
getExpectedIccNumberOfComponents
private int getExpectedIccNumberOfComponents() -
checkIccProfile
private void checkIccProfile() -
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
-