Package com.itextpdf.text.pdf.codec
Class PngImage
- java.lang.Object
-
- com.itextpdf.text.pdf.codec.PngImage
-
public class PngImage extends java.lang.ObjectReads 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 (package private) static classPngImage.NewByteArrayOutputStream
-
Field Summary
Fields Modifier and Type Field Description (package private) PdfDictionaryadditional(package private) intbitDepth(package private) intbytesPerPixelstatic java.lang.StringcHRMA PNG marker.(package private) byte[]colorTable(package private) intcolorType(package private) intcompressionMethod(package private) java.io.DataInputStreamdataStream(package private) intdpiX(package private) intdpiY(package private) intfilterMethodstatic java.lang.StringgAMAA PNG marker.(package private) floatgamma(package private) booleangenBWMask(package private) booleanhasCHRM(package private) intheight(package private) ICC_Profileicc_profilestatic java.lang.StringiCCPA PNG marker.(package private) PngImage.NewByteArrayOutputStreamidatstatic java.lang.StringIDATA PNG marker.static java.lang.StringIENDA PNG marker.static java.lang.StringIHDRA PNG marker.(package private) byte[]image(package private) intinputBands(package private) PdfNameintentprivate static PdfName[]intents(package private) intinterlaceMethod(package private) java.io.InputStreamis(package private) booleanpalShadesstatic java.lang.StringpHYsA PNG marker.static java.lang.StringPLTEA PNG marker.private static intPNG_FILTER_AVERAGEprivate static intPNG_FILTER_NONEprivate static intPNG_FILTER_PAETHprivate static intPNG_FILTER_SUBprivate static intPNG_FILTER_UPstatic int[]PNGIDSome PNG specific values.(package private) byte[]smaskstatic java.lang.StringsRGBA PNG marker.(package private) byte[]trans(package private) inttransBlueprivate static intTRANSFERSIZE(package private) inttransGreen(package private) inttransRedGraystatic java.lang.StringtRNSA PNG marker.(package private) intwidth(package private) floatxB(package private) floatxG(package private) floatxR(package private) floatxW(package private) floatXYRatio(package private) floatyB(package private) floatyG(package private) floatyR(package private) floatyW
-
Constructor Summary
Constructors Constructor Description 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 voidcheckIccProfile()(package private) booleancheckMarker(java.lang.String s)private static voiddecodeAverageFilter(byte[] curr, byte[] prev, int count, int bpp)(package private) voiddecodeIdat()private static voiddecodePaethFilter(byte[] curr, byte[] prev, int count, int bpp)(package 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)(package private) PdfObjectgetColorspace()private intgetExpectedIccNumberOfComponents()(package private) ImagegetImage()static ImagegetImage(byte[] data)Reads a PNG from a byte array.static ImagegetImage(java.io.InputStream is)Reads a PNG from a stream.static ImagegetImage(java.lang.String file)Reads a PNG from a file.static ImagegetImage(java.net.URL url)Reads a PNG from an url.static intgetInt(java.io.InputStream is)Gets anintfrom anInputStream.(package private) int[]getPixel(byte[] curr)(package private) static intgetPixel(byte[] image, int x, int y, int bitDepth, int bytesPerRow)static java.lang.StringgetString(java.io.InputStream is)Gets aStringfrom anInputStream.static intgetWord(java.io.InputStream is)Gets awordfrom anInputStream.private static intpaethPredictor(int a, int b, int c)(package private) voidprocessPixels(byte[] curr, int xOffset, int step, int y, int width)(package private) voidreadPng()(package private) static voidsetPixel(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
public static final java.lang.String IHDR
A PNG marker.- See Also:
- Constant Field Values
-
PLTE
public static final java.lang.String PLTE
A PNG marker.- See Also:
- Constant Field Values
-
IDAT
public static final java.lang.String IDAT
A PNG marker.- See Also:
- Constant Field Values
-
IEND
public static final java.lang.String IEND
A PNG marker.- See Also:
- Constant Field Values
-
tRNS
public static final java.lang.String tRNS
A PNG marker.- See Also:
- Constant Field Values
-
pHYs
public static final java.lang.String pHYs
A PNG marker.- See Also:
- Constant Field Values
-
gAMA
public static final java.lang.String gAMA
A PNG marker.- See Also:
- Constant Field Values
-
cHRM
public static final java.lang.String cHRM
A PNG marker.- See Also:
- Constant Field Values
-
sRGB
public static final java.lang.String sRGB
A PNG marker.- See Also:
- Constant Field Values
-
iCCP
public 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
java.io.InputStream is
-
dataStream
java.io.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
PngImage.NewByteArrayOutputStream 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
-
-
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
public 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(java.lang.String file) throws java.io.IOException
Reads a PNG from a file.- Parameters:
file- the file- 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
boolean checkMarker(java.lang.String s)
-
readPng
void readPng() throws java.io.IOException- Throws:
java.io.IOException
-
getColorspace
PdfObject getColorspace()
-
getImage
Image getImage() throws java.io.IOException
- Throws:
java.io.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
public static final int getInt(java.io.InputStream is) throws java.io.IOExceptionGets anintfrom anInputStream.- Parameters:
is- anInputStream- Returns:
- the value of an
int - Throws:
java.io.IOException
-
getWord
public static final int getWord(java.io.InputStream is) throws java.io.IOExceptionGets awordfrom anInputStream.- Parameters:
is- anInputStream- Returns:
- the value of an
int - Throws:
java.io.IOException
-
getString
public static final java.lang.String getString(java.io.InputStream is) throws java.io.IOExceptionGets aStringfrom anInputStream.- Parameters:
is- anInputStream- Returns:
- the value of an
int - Throws:
java.io.IOException
-
-