public interface PDImage extends COSObjectable
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.
|
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 |
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 |
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.
|
BufferedImage getImage() throws IOException
IOException
- if the buffered image could not be createdWritableRaster getRawRaster() throws IOException
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.IOException
- if the buffered raw writable raster could not be createdBufferedImage getRawImage() throws IOException
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 getRawRaster()
, if you want to access the raw data even if no matching
java.awt.ColorSpace existsIOException
- if the raw image could not be createdBufferedImage getImage(Rectangle region, int subsampling) throws IOException
the unparameterized version
, this method does not cache the resulting
image.region
- 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 createdBufferedImage getStencilImage(Paint paint) throws IOException
paint
- the paint to fill the visible portions of the image withIOException
- if the image cannot be readIllegalStateException
- if the image is not a stencil.InputStream createInputStream() throws IOException
IOException
- if the data could not be read.InputStream createInputStream(List<String> stopFilters) throws IOException
stopFilters
- A list of filters to stop decoding at.IOException
- if the data could not be read.InputStream createInputStream(DecodeOptions options) throws IOException
DecodeOptions
.options
- Additional decoding options passed to the filters usedIOException
- if the data could not be readboolean isEmpty()
boolean isStencil()
void setStencil(boolean isStencil)
ImageMask
entry in the image stream's dictionary.isStencil
- True to make the image a stencil.int getBitsPerComponent()
void setBitsPerComponent(int bitsPerComponent)
bitsPerComponent
- The number of bits per component.PDColorSpace getColorSpace() throws IOException
IOException
- If there is an error getting the color space.void setColorSpace(PDColorSpace colorSpace)
colorSpace
- The color space for this image.int getHeight()
void setHeight(int height)
height
- The height of the image.int getWidth()
void setWidth(int width)
width
- The width of the image.void setDecode(COSArray decode)
decode
- the new decode array.COSArray getDecode()
boolean getInterpolate()
void setInterpolate(boolean value)
value
- true for high-quality image scalingString getSuffix()
COSDictionary getCOSObject()
getCOSObject
in interface COSObjectable
Copyright © 2002–2025 The Apache Software Foundation. All rights reserved.