public final class PDImageXObject extends PDXObject implements PDImage
| Constructor and Description |
|---|
PDImageXObject()
Creates an Image XObject in the given document.
|
PDImageXObject(InputStream encodedStream,
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 |
|---|---|
ByteBuffer |
asByteBuffer() |
static PDImageXObject |
createFromFile(File file) |
static PDImageXObject |
createFromFile(String imagePath) |
InputStream |
createInputStream()
Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image
XObject.
|
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.
|
BufferedImage |
getImageWithoutMasks() |
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.
|
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.
|
int |
getStructParent()
Returns the key of this XObject in the structural parent tree.
|
int |
getWidth()
Returns the width of this image, or -1 if one has not been set.
|
boolean |
isEmpty()
Returns true if the image has no data.
|
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, getStream, setStreamclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCOSObjectpublic PDImageXObject()
throws IOException
IOException - if there is an error creating the XObject.public PDImageXObject(InputStream encodedStream, COSBase cosFilter, int width, int height, int bitsPerComponent, PDColorSpace initColorSpace) throws IOException
encodedStream - 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) throws IOException
IOExceptionpublic static PDImageXObject createFromFile(File file) throws IOException
IOExceptionpublic 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 getImageWithoutMasks() throws IOException
IOExceptionpublic 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 InputStream createInputStream() throws IOException
PDImagecreateInputStream in interface PDImageIOException - if the data could not be read.public ByteBuffer asByteBuffer() throws IOException
asByteBuffer in interface PDImageByteBufferIOExceptionpublic boolean isEmpty()
throws IOException
PDImageisEmpty in interface PDImageIOExceptionpublic void setColorSpace(PDColorSpace cs)
PDImagesetColorSpace in interface PDImagecs - The color space for this image.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 © 2019 sejda. All rights reserved.