public final class PDImageXObject extends PDXObject implements PDImage
| Constructor and Description |
|---|
PDImageXObject(PDDocument document)
Creates an Image XObject in the given document.
|
PDImageXObject(PDDocument document,
InputStream filteredStream,
COSBase cosFilter,
int width,
int height,
int bitsPerComponent,
PDColorSpace initColorSpace)
Creates an Image XObject in the given document using the given filtered stream.
|
PDImageXObject(PDStream stream,
PDResources resources)
Creates an Image XObject with the given stream as its contents and current color spaces.
|
| Modifier and Type | Method and Description |
|---|---|
static PDImageXObject |
createFromFile(File file,
PDDocument doc)
Create a PDImageXObject from an image file.
|
static PDImageXObject |
createFromFile(String imagePath,
PDDocument doc)
Create a PDImageXObject from an image file, see
createFromFile(File, PDDocument) for
more details. |
static PDImageXObject |
createThumbnail(COSStream cosStream)
Creates a thumbnail Image XObject from the given COSBase and name.
|
int |
getBitsPerComponent()
Returns bits per component of this image, or -1 if one has not been set.
|
COSArray |
getColorKeyMask()
Returns the color key mask array associated with this image, or null if there is none.
|
PDColorSpace |
getColorSpace()
Returns the image's color space.
|
COSArray |
getDecode()
Returns the decode array.
|
int |
getHeight()
Returns height of this image, or -1 if one has not been set.
|
BufferedImage |
getImage()
Returns the content of this image as an AWT buffered image with an (A)RGB color space.
|
boolean |
getInterpolate()
Returns true if the image should be interpolated when rendered.
|
PDImageXObject |
getMask()
Returns the Mask Image XObject associated with this image, or null if there is none.
|
PDMetadata |
getMetadata()
Returns the metadata associated with this XObject, or null if there is none.
|
BufferedImage |
getOpaqueImage()
Returns an RGB buffered image containing the opaque image stream without any masks applied.
|
PDResources |
getResources() |
PDImageXObject |
getSoftMask()
Returns the Soft Mask Image XObject associated with this image, or null if there is none.
|
BufferedImage |
getStencilImage(Paint paint)
Returns an ARGB image filled with the given paint and using this image as a mask.
|
PDStream |
getStream()
Returns a stream containing this image's data.
|
int |
getStructParent()
Returns the key of this XObject in the structural parent tree.
|
String |
getSuffix()
This will get the suffix for this image type, e.g.
|
int |
getWidth()
Returns the width of this image, or -1 if one has not been set.
|
boolean |
isStencil()
Returns true if the image is a stencil mask.
|
void |
setBitsPerComponent(int bpc)
Set the number of bits per component.
|
void |
setColorSpace(PDColorSpace cs)
Sets the color space for this image.
|
void |
setDecode(COSArray decode)
Sets the decode array.
|
void |
setHeight(int h)
Sets the height of the image.
|
void |
setInterpolate(boolean value)
Sets the Interpolate flag, true for high-quality image scaling.
|
void |
setMetadata(PDMetadata meta)
Sets the metadata associated with this XObject, or null if there is none.
|
void |
setStencil(boolean isStencil)
Sets whether or not the image is a stencil.
|
void |
setStructParent(int key)
Sets the key of this XObject in the structural parent tree.
|
void |
setWidth(int w)
Sets the width of the image.
|
createXObject, getCOSObject, getCOSStream, getPDStream, isInherited, setInheritedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCOSObjectpublic PDImageXObject(PDDocument document) throws IOException
document - the current documentIOException - if there is an error creating the XObject.public PDImageXObject(PDDocument document, InputStream filteredStream, COSBase cosFilter, int width, int height, int bitsPerComponent, PDColorSpace initColorSpace) throws IOException
document - the current documentfilteredStream - a filtered stream of image datacosFilter - the filter or a COSArray of filterswidth - the image widthheight - the image heightbitsPerComponent - the bits per componentinitColorSpace - the color spaceIOException - if there is an error creating the XObject.public PDImageXObject(PDStream stream, PDResources resources) throws IOException
stream - the XObject stream to readresources - the current resourcesIOException - if there is an error creating the XObject.public static PDImageXObject createThumbnail(COSStream cosStream) throws IOException
cosStream - the COS streamIOException - if there is an error creating the XObject.public static PDImageXObject createFromFile(String imagePath, PDDocument doc) throws IOException
createFromFile(File, PDDocument) for
more details.imagePath - the image file path.doc - the document that shall use this PDImageXObject.IOException - if there is an error when reading the file or creating the
PDImageXObject, or if the image type is not supported.public static PDImageXObject createFromFile(File file, PDDocument doc) throws IOException
JPEGFactory.createFromStream(org.apache.pdfbox.pdmodel.PDDocument, java.io.InputStream),
CCITTFactory.createFromFile(org.apache.pdfbox.pdmodel.PDDocument, java.io.File) or ImageIO.read(java.io.File) combined with
LosslessFactory.createFromImage(org.apache.pdfbox.pdmodel.PDDocument, java.awt.image.BufferedImage). (The later can also be used to create a
PDImageXObject from a BufferedImage).file - the image file.doc - the document that shall use this PDImageXObject.IOException - if there is an error when reading the file or creating the
PDImageXObject.IllegalArgumentException - if the image type is not supported.public PDMetadata getMetadata()
public void setMetadata(PDMetadata meta)
meta - the metadata associated with this objectpublic int getStructParent()
public void setStructParent(int key)
key - the new key for this XObjectpublic BufferedImage getImage() throws IOException
getImage in interface PDImageIOExceptionpublic BufferedImage getStencilImage(Paint paint) throws IOException
getStencilImage in interface PDImagepaint - the paint to fill the visible portions of the image withIOException - if the image cannot be readpublic BufferedImage getOpaqueImage() throws IOException
IOException - if the image cannot be readpublic PDImageXObject getMask() throws IOException
IOExceptionpublic COSArray getColorKeyMask()
public PDImageXObject getSoftMask() throws IOException
IOExceptionpublic int getBitsPerComponent()
PDImagegetBitsPerComponent in interface PDImagepublic void setBitsPerComponent(int bpc)
PDImagesetBitsPerComponent in interface PDImagebpc - The number of bits per component.public PDColorSpace getColorSpace() throws IOException
PDImagegetColorSpace in interface PDImageIOException - If there is an error getting the color space.public PDStream getStream() throws IOException
PDImagegetStream in interface PDImageIOException - if thepublic void setColorSpace(PDColorSpace cs)
PDImagesetColorSpace in interface PDImagecs - The color space for this image.public PDResources getResources()
public int getHeight()
PDImagepublic void setHeight(int h)
PDImagepublic int getWidth()
PDImagepublic void setWidth(int w)
PDImagepublic boolean getInterpolate()
PDImagegetInterpolate in interface PDImagepublic void setInterpolate(boolean value)
PDImagesetInterpolate in interface PDImagepublic void setDecode(COSArray decode)
PDImagepublic COSArray getDecode()
PDImagepublic boolean isStencil()
PDImagepublic void setStencil(boolean isStencil)
PDImageImageMask entry in the image stream's dictionary.setStencil in interface PDImageisStencil - True to make the image a stencil.Copyright © 2015–2019 The veraPDF Consortium. All rights reserved.