Package com.itextpdf.text.pdf.parser
Class PdfImageObject
- java.lang.Object
-
- com.itextpdf.text.pdf.parser.PdfImageObject
-
public class PdfImageObject extends java.lang.Object
An object that contains an image dictionary and image bytes.- Since:
- 5.0.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PdfImageObject.ImageBytesType
Different types of data that can be stored in the bytes of aPdfImageObject
private static class
PdfImageObject.TrackingFilter
A filter that does nothing, but keeps track of the filter type that was used
-
Field Summary
Fields Modifier and Type Field Description private int
bpc
private PdfDictionary
colorSpaceDic
private PdfDictionary
dictionary
The image dictionary.private int
height
private byte[]
icc
private byte[]
imageBytes
The decoded image bytes (after applying filters), or the raw image bytes if unable to decodeprivate byte[]
palette
private int
pngBitDepth
private int
pngColorType
private PdfImageObject.ImageBytesType
streamContentType
Tracks the type of data that is actually stored in the streamBytes memberprivate int
stride
private int
width
-
Constructor Summary
Constructors Modifier Constructor Description protected
PdfImageObject(PdfDictionary dictionary, byte[] samples, PdfDictionary colorSpaceDic)
Creats a PdfImage object using an explicitly provided dictionary and image bytesPdfImageObject(PRStream stream)
Creates a PdfImage object.PdfImageObject(PRStream stream, PdfDictionary colorSpaceDic)
Creates a PdfImage object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
decodeImageBytes()
decodes the bytes currently captured in the streamBytes and replaces it with an image representation of the bytes (this will either be a png or a tiff, depending on the color depth of the image)private void
findColorspace(PdfObject colorspace, boolean allowIndexed)
Sets state of this object according to the color spacePdfObject
get(PdfName key)
Returns an entry from the image dictionary.java.awt.image.BufferedImage
getBufferedImage()
PdfDictionary
getDictionary()
Returns the image dictionary.java.lang.String
getFileType()
byte[]
getImageAsBytes()
PdfImageObject.ImageBytesType
getImageBytesType()
-
-
-
Field Detail
-
dictionary
private PdfDictionary dictionary
The image dictionary.
-
imageBytes
private byte[] imageBytes
The decoded image bytes (after applying filters), or the raw image bytes if unable to decode
-
colorSpaceDic
private PdfDictionary colorSpaceDic
-
pngColorType
private int pngColorType
-
pngBitDepth
private int pngBitDepth
-
width
private int width
-
height
private int height
-
bpc
private int bpc
-
palette
private byte[] palette
-
icc
private byte[] icc
-
stride
private int stride
-
streamContentType
private PdfImageObject.ImageBytesType streamContentType
Tracks the type of data that is actually stored in the streamBytes member
-
-
Constructor Detail
-
PdfImageObject
public PdfImageObject(PRStream stream) throws java.io.IOException
Creates a PdfImage object.- Parameters:
stream
- a PRStream- Throws:
java.io.IOException
-
PdfImageObject
public PdfImageObject(PRStream stream, PdfDictionary colorSpaceDic) throws java.io.IOException
Creates a PdfImage object.- Parameters:
stream
- a PRStreamcolorSpaceDic
- a color space dictionary- Throws:
java.io.IOException
-
PdfImageObject
protected PdfImageObject(PdfDictionary dictionary, byte[] samples, PdfDictionary colorSpaceDic) throws java.io.IOException
Creats a PdfImage object using an explicitly provided dictionary and image bytes- Parameters:
dictionary
- the dictionary for the imagesamples
- the samplescolorSpaceDic
- a color space dictionary- Throws:
java.io.IOException
- Since:
- 5.0.3
-
-
Method Detail
-
getFileType
public java.lang.String getFileType()
-
getImageBytesType
public PdfImageObject.ImageBytesType getImageBytesType()
- Returns:
- the type of image data that is returned by getImageBytes()
-
get
public PdfObject get(PdfName key)
Returns an entry from the image dictionary.- Parameters:
key
- a key- Returns:
- the value
-
getDictionary
public PdfDictionary getDictionary()
Returns the image dictionary.- Returns:
- the dictionary
-
findColorspace
private void findColorspace(PdfObject colorspace, boolean allowIndexed) throws java.io.IOException
Sets state of this object according to the color space- Parameters:
colorspace
- the colorspace to useallowIndexed
- whether indexed color spaces will be resolved (used for recursive call)- Throws:
java.io.IOException
- if there is a problem with reading from the underlying stream
-
decodeImageBytes
private void decodeImageBytes() throws java.io.IOException
decodes the bytes currently captured in the streamBytes and replaces it with an image representation of the bytes (this will either be a png or a tiff, depending on the color depth of the image)- Throws:
java.io.IOException
-
getImageAsBytes
public byte[] getImageAsBytes()
- Returns:
- the bytes of the image (the format will be as specified in
getImageBytesType()
- Throws:
java.io.IOException
- Since:
- 5.0.4
-
getBufferedImage
public java.awt.image.BufferedImage getBufferedImage() throws java.io.IOException
- Throws:
java.io.IOException
- Since:
- 5.0.3 renamed from getAwtImage()
-
-