public final class PDInlineImage extends Object implements PDImage
| Constructor and Description |
|---|
PDInlineImage(COSDictionary parameters,
byte[] data,
PDResources resources)
Creates an inline image from the given parameters and data.
|
| Modifier and Type | Method and Description |
|---|---|
InputStream |
createInputStream()
Returns an InputStream containing the image data, irrespective of whether this is an
inline image or an image XObject.
|
InputStream |
createInputStream(DecodeOptions options)
Returns an InputStream, passing additional options to each filter.
|
InputStream |
createInputStream(List<String> stopFilters)
Returns an InputStream containing the image data, irrespective of whether this is an
inline image or an image XObject.
|
int |
getBitsPerComponent()
Returns bits per component of this image, or -1 if one has not been set.
|
PDColorSpace |
getColorSpace()
Returns the image's color space.
|
COSDictionary |
getCOSObject()
Convert this image to a COS object.
|
byte[] |
getData()
Returns the inline image data.
|
COSArray |
getDecode()
Returns the decode array.
|
List<String> |
getFilters()
Returns A list of filters applied to this stream.
|
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 |
getImage(Rectangle region,
int subsampling)
Returns the content of this image as an AWT buffered image with an (A)RGB colored space.
|
boolean |
getInterpolate()
Returns true if the image should be interpolated when rendered.
|
BufferedImage |
getRawImage()
Try to get the raw image as AWT buffered image with it's original colorspace.
|
WritableRaster |
getRawRaster()
Return the image data as WritableRaster.
|
BufferedImage |
getStencilImage(Paint paint)
Returns an ARGB image filled with the given paint and using this image as a mask.
|
String |
getSuffix()
Returns 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 |
isEmpty()
Returns true if the image has no data.
|
boolean |
isStencil()
Returns true if the image is a stencil mask.
|
void |
setBitsPerComponent(int bitsPerComponent)
Set the number of bits per component.
|
void |
setColorSpace(PDColorSpace colorSpace)
Sets the color space for this image.
|
void |
setDecode(COSArray decode)
Sets the decode array.
|
void |
setFilters(List<String> filters)
Sets which filters are applied to this stream.
|
void |
setHeight(int height)
Sets the height of the image.
|
void |
setInterpolate(boolean value)
Sets the Interpolate flag, true for high-quality image scaling.
|
void |
setStencil(boolean isStencil)
Sets whether or not the image is a stencil.
|
void |
setWidth(int width)
Sets the width of the image.
|
public PDInlineImage(COSDictionary parameters, byte[] data, PDResources resources) throws IOException
parameters - the image parametersdata - the image dataresources - the current resourcesIOException - if the stream cannot be decodedpublic COSDictionary getCOSObject()
PDImagegetCOSObject in interface COSObjectablegetCOSObject in interface PDImagepublic int getBitsPerComponent()
PDImagegetBitsPerComponent in interface PDImagepublic void setBitsPerComponent(int bitsPerComponent)
PDImagesetBitsPerComponent in interface PDImagebitsPerComponent - 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 void setColorSpace(PDColorSpace colorSpace)
PDImagesetColorSpace in interface PDImagecolorSpace - The color space for this image.public int getHeight()
PDImagepublic void setHeight(int height)
PDImagepublic int getWidth()
PDImagepublic void setWidth(int width)
PDImagepublic boolean getInterpolate()
PDImagegetInterpolate in interface PDImagepublic void setInterpolate(boolean value)
PDImagesetInterpolate in interface PDImagevalue - true for high-quality image scalingpublic List<String> getFilters()
public void setFilters(List<String> filters)
filters - the filters to apply to this stream.public 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.public InputStream createInputStream() throws IOException
PDImagecreateInputStream in interface PDImageIOException - if the data could not be read.public InputStream createInputStream(DecodeOptions options) throws IOException
PDImageDecodeOptions.createInputStream in interface PDImageoptions - Additional decoding options passed to the filters usedIOException - if the data could not be readpublic InputStream createInputStream(List<String> stopFilters) throws IOException
PDImagecreateInputStream in interface PDImagestopFilters - A list of filters to stop decoding at.IOException - if the data could not be read.public boolean isEmpty()
PDImagepublic byte[] getData()
public BufferedImage getImage() throws IOException
PDImagegetImage in interface PDImageIOException - if the buffered image could not be createdpublic BufferedImage getImage(Rectangle region, int subsampling) throws IOException
PDImagethe unparameterized version, this method does not cache the resulting
image.getImage in interface PDImageregion - The region of the source image to get, or null if the entire image is needed. The actual region
will be clipped to the dimensions of the source image.subsampling - The amount of rows and columns to advance for every output pixel, a value of 1 meaning every
pixel will be readIOException - if the buffered image could not be createdpublic WritableRaster getRawRaster() throws IOException
PDImagePDImage.getColorSpace()
to know how to interpret the data in this WritableRaster.
Use this if e.g. want access to the raw color information of a
PDDeviceN image.getRawRaster in interface PDImageIOException - if the buffered raw writable raster could not be createdpublic BufferedImage getRawImage() throws IOException
PDImagePDImage.getImage() for that.
This method returns null if it is not possible to map the underlying colorspace into a java.awt.ColorSpace.
Use this method if you want to extract the image without loosing any color information, as no color conversion
will be performed.
You can alwoys use PDImage.getRawRaster(), if you want to access the raw data even if no matching
java.awt.ColorSpace existsgetRawImage in interface PDImageIOException - if the raw image could not be createdpublic BufferedImage getStencilImage(Paint paint) throws IOException
PDImagegetStencilImage in interface PDImagepaint - the paint to fill the visible portions of the image withIOException - if the image cannot be readCopyright © 2002–2022 The Apache Software Foundation. All rights reserved.