| Modifier and Type | Field and Description |
|---|---|
| private SoftReference | |
| private int | |
| private PDColorSpace | |
| private boolean | |
| private BufferedImage | |
| private boolean | |
| private static final Log | LOG
Log instance. |
| private final PDResources | resources
current resource dictionary (has color spaces) |
| Access | Constructor and Description |
|---|---|
| public | PDImageXObject(PDDocument
the current document document)Creates an Image XObject in the given document. |
| public | PDImageXObject(PDDocument
the current document document, InputStream an encoded stream of image data encodedStream, COSBase the filter or a COSArray of filters cosFilter, int the image width width, int the image height height, int the bits per component bitsPerComponent, PDColorSpace the color space initColorSpace)Creates an Image XObject in the given document using the given filtered stream. |
| public | PDImageXObject(PDStream
the XObject stream to read stream, PDResources the current resources resources)Creates an Image XObject with the given stream as its contents and current color spaces. |
| Modifier and Type | Method and Description |
|---|---|
| private BufferedImage | Returns: an ARGB image (can be the altered original image)The image to apply the mask to as alpha channel. image, BufferedImage A mask image in 8 bit Gray. Even for a stencil mask image due to
mask, boolean getOpaqueImage() and SampledImageReader's from1Bit() special
handling of DeviceGray.interpolation flag of the mask image. interpolateMask, boolean true if a soft mask. If not stencil mask, then alpha will be inverted
by this method.an optional RGB matte if a soft mask. matte)
|
| private static int | |
| public static PDImageXObject | Returns: a PDImageXObject.the document that shall use this PDImageXObject. document, byte[] bytes from an image file. byteArray, String name of image file for exception messages, can be null. name)Create a PDImageXObject from bytes of an image file. |
| public static PDImageXObject | Returns: a PDImageXObject.the image file path. imagePath, PDDocument the document that shall use this PDImageXObject. doc)Create a PDImageXObject from an image file, see |
| public static PDImageXObject | Returns: a PDImageXObject.the image file. file, PDDocument the document that shall use this PDImageXObject. doc)Create a PDImageXObject from an image file. |
| public static PDImageXObject | Returns: a PDImageXObject.the image file. file, PDDocument the document that shall use this PDImageXObject. doc)Create a PDImageXObject from an image file. |
| public InputStream | createInputStream()
Implements org. Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject. |
| public InputStream | createInputStream(DecodeOptions
Additional decoding options passed to the filters used options)Implements org. Returns an InputStream, passing additional options to each filter. |
| public InputStream | createInputStream(List<String>
A list of filters to stop decoding at. stopFilters)Implements org. Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject. |
| private static COSStream | createRawStream(PDDocument document, InputStream rawInput)
Creates a COS stream from raw (encoded) data. |
| public static PDImageXObject | Returns: an XObjectthe COS stream cosStream)Creates a thumbnail Image XObject from the given COSBase and name. |
| private float[] | Returns: the matte color.Extract the matte color from a softmask. |
| public int | getBitsPerComponent()
Implements org. Returns bits per component of this image, or -1 if one has not been set. |
| public COSArray | Returns: Mask Image XObjectReturns the color key mask array associated with this image, or null if there is none. |
| public PDColorSpace | getColorSpace()
Implements org. Returns the image's color space. |
| public COSArray | getDecode()
Implements org. Returns the decode array. |
| public int | getHeight()
Implements org. Returns height of this image, or -1 if one has not been set. |
| public BufferedImage | getImage()
Implements org. Returns the content of this image as an AWT buffered image with an (A)RGB color space. |
| public BufferedImage | getImage(Rectangle
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. region, int The amount of rows and columns to advance for every output pixel, a value of 1 meaning every
pixel will be read subsampling)Implements org. Returns the content of this image as an AWT buffered image with an (A)RGB colored space. |
| public boolean | getInterpolate()
Implements org. Returns true if the image should be interpolated when rendered. |
| public PDImageXObject | Returns: Mask Image XObjectReturns the Mask Image XObject associated with this image, or null if there is none. |
| public PDMetadata | Returns: the metadata associated with this object.Returns the metadata associated with this XObject, or null if there is none. |
| public BufferedImage | Returns: the image without any masks appliedReturns an RGB buffered image containing the opaque image stream without any masks applied. |
| public BufferedImage | Returns: the image without any masks appliedThe 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. region, int The amount of rows and columns to advance for every output pixel, a value of 1 meaning every
pixel will be read. It must not be larger than the image width or height. subsampling)Returns an RGB buffered image containing the opaque image stream without any masks applied. |
| public PDPropertyList | Returns: The optional content group or optional content membership dictionary or null if there is none.This will get the optional content group or optional content membership dictionary. |
| public BufferedImage | getRawImage()
Implements org. Try to get the raw image as AWT buffered image with it's original colorspace. |
| public WritableRaster | getRawRaster()
Implements org. Return the image data as WritableRaster. |
| public PDImageXObject | Returns: the SMask Image XObject, or null.Returns the Soft Mask Image XObject associated with this image, or null if there is none. |
| public BufferedImage | getStencilImage(Paint
the paint to fill the visible portions of the image with paint)Implements org. Returns an ARGB image filled with the given paint and using this image as a mask. |
| public int | Returns: this object's key the structural parent tree or -1 if there isn't any.Returns the key of this XObject in the structural parent tree. |
| public String | Returns: The image suffix or null if not available.Implements org. This will get the suffix for this image type, e.g. jpg/png. |
| public int | getWidth()
Implements org. Returns the width of this image, or -1 if one has not been set. |
| private void | |
| public boolean | isEmpty()
Implements org. Returns true if the image has no data. |
| public boolean | isStencil()
Implements org. Returns true if the image is a stencil mask. |
| private static BufferedImage | scaleImage(BufferedImage image, int width, int height, int type, boolean interpolate)
High-quality image scaling. |
| public void | setBitsPerComponent(int
The number of bits per component. bpc)Implements org. Set the number of bits per component. |
| public void | setColorSpace(PDColorSpace
The color space for this image. cs)Implements org. Sets the color space for this image. |
| public void | setDecode(COSArray
the new decode array. decode)Implements org. Sets the decode array. |
| public void | setHeight(int
The height of the image. h)Implements org. Sets the height of the image. |
| public void | setInterpolate(boolean
true for high-quality image scaling value)Implements org. Sets the Interpolate flag, true for high-quality image scaling. |
| public void | setMetadata(PDMetadata
the metadata associated with this object meta)Sets the metadata associated with this XObject, or null if there is none. |
| public void | setOptionalContent(PDPropertyList
The optional content group or optional content membership dictionary. oc)Sets the optional content group or optional content membership dictionary. |
| public void | setStencil(boolean
True to make the image a stencil. isStencil)Implements org. Sets whether or not the image is a stencil. |
| public void | setStructParent(int
the new key for this XObject key)Sets the key of this XObject in the structural parent tree. |
| public void | setWidth(int
The width of the image. w)Implements org. Sets the width of the image. |
| cachedImage | back to summary |
|---|---|
| private SoftReference<BufferedImage> cachedImage | |
| cachedImageSubsampling | back to summary |
|---|---|
| private int cachedImageSubsampling | |
| colorSpace | back to summary |
|---|---|
| private PDColorSpace colorSpace | |
| hasJPXFilter | back to summary |
|---|---|
| private boolean hasJPXFilter | |
| jpxSMask | back to summary |
|---|---|
| private BufferedImage jpxSMask | |
| jpxValuesInitialized | back to summary |
|---|---|
| private boolean jpxValuesInitialized | |
| LOG | back to summary |
|---|---|
| private static final Log LOG Log instance. | |
| resources | back to summary |
|---|---|
| private final PDResources resources current resource dictionary (has color spaces) | |
| PDImageXObject | back to summary |
|---|---|
| public PDImageXObject(PDDocument document) throws IOException Creates an Image XObject in the given document. This constructor is for internal PDFBox use
and is not for PDF generation. Users who want to create images should look at
| |
| PDImageXObject | back to summary |
|---|---|
| public PDImageXObject(PDDocument document, InputStream encodedStream, COSBase cosFilter, int width, int height, int bitsPerComponent, PDColorSpace initColorSpace) throws IOException Creates an Image XObject in the given document using the given filtered stream. This
constructor is for internal PDFBox use and is not for PDF generation. Users who want to
create images should look at
| |
| PDImageXObject | back to summary |
|---|---|
| public PDImageXObject(PDStream stream, PDResources resources) throws IOException Creates an Image XObject with the given stream as its contents and current color spaces. This
constructor is for internal PDFBox use and is not for PDF generation. Users who want to
create images should look at
| |
| applyMask | back to summary |
|---|---|
private BufferedImage applyMask(BufferedImage image, BufferedImage mask, boolean interpolateMask, boolean isSoft, float[] matte)
| |
| clampColor | back to summary |
|---|---|
| private static int clampColor(int color) | |
| createFromByteArray | back to summary |
|---|---|
| public static PDImageXObject createFromByteArray(PDDocument document, byte[] byteArray, String name) throws IOException Create a PDImageXObject from bytes of an image file. The file format is determined by the
file content. The following file types are supported: JPG, JPEG, TIF, TIFF, GIF, BMP and PNG.
This is a convenience method that calls
| |
| createFromFile | back to summary |
|---|---|
| public static PDImageXObject createFromFile(String imagePath, PDDocument doc) throws IOException Create a PDImageXObject from an image file, see
| |
| createFromFileByContent | back to summary |
|---|---|
| public static PDImageXObject createFromFileByContent(File file, PDDocument doc) throws IOException Create a PDImageXObject from an image file. The file format is determined by the file
content. The following file types are supported: JPG, JPEG, TIF, TIFF, GIF, BMP and PNG. This
is a convenience method that calls
| |
| createFromFileByExtension | back to summary |
|---|---|
| public static PDImageXObject createFromFileByExtension(File file, PDDocument doc) throws IOException Create a PDImageXObject from an image file. The file format is determined by the file name
suffix. The following suffixes are supported: JPG, JPEG, TIF, TIFF, GIF, BMP and PNG. This is
a convenience method that calls
| |
| createInputStream | back to summary |
|---|---|
| public InputStream createInputStream() throws IOException Implements org. Doc from org. Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject.
| |
| createInputStream | back to summary |
|---|---|
| public InputStream createInputStream(DecodeOptions options) throws IOException Implements org. Doc from org. Returns an InputStream, passing additional options to each filter. As a side effect, the
filterSubsampled flag is set in
| |
| createInputStream | back to summary |
|---|---|
| public InputStream createInputStream(List<String> stopFilters) throws IOException Implements org. Doc from org. Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject. The given filters will not be decoded.
| |
| createRawStream | back to summary |
|---|---|
| private static COSStream createRawStream(PDDocument document, InputStream rawInput) throws IOException Creates a COS stream from raw (encoded) data. | |
| createThumbnail | back to summary |
|---|---|
| public static PDImageXObject createThumbnail(COSStream cosStream) throws IOException Creates a thumbnail Image XObject from the given COSBase and name.
| |
| extractMatte | back to summary |
|---|---|
| private float[] extractMatte(PDImageXObject softMask) throws IOException Extract the matte color from a softmask.
| |
| getBitsPerComponent | back to summary |
|---|---|
| public int getBitsPerComponent() Implements org. Doc from org. Returns bits per component of this image, or -1 if one has not been set.
| |
| getColorKeyMask | back to summary |
|---|---|
| public COSArray getColorKeyMask() Returns the color key mask array associated with this image, or null if there is none.
| |
| getColorSpace | back to summary |
|---|---|
| public PDColorSpace getColorSpace() throws IOException Implements org. Doc from org. Returns the image's color space.
| |
| getDecode | back to summary |
|---|---|
| public COSArray getDecode() Implements org. Doc from org. Returns the decode array. | |
| getHeight | back to summary |
|---|---|
| public int getHeight() Implements org. Doc from org. Returns height of this image, or -1 if one has not been set.
| |
| getImage | back to summary |
|---|---|
| public BufferedImage getImage() throws IOException Implements org. Doc from org. Returns the content of this image as an AWT buffered image with an (A)RGB color space. The size of the returned image is the larger of the size of the image itself or its mask. The returned images are cached via a SoftReference.
| |
| getImage | back to summary |
|---|---|
| public BufferedImage getImage(Rectangle region, int subsampling) throws IOException Implements org. Doc from org. Returns the content of this image as an AWT buffered image with an (A)RGB colored space. Only the subregion
specified is rendered, and is subsampled by advancing the specified amount of rows and columns in the source
image for every resulting pixel.
Note that unlike
| |
| getInterpolate | back to summary |
|---|---|
| public boolean getInterpolate() Implements org. Doc from org. Returns true if the image should be interpolated when rendered.
| |
| getMask | back to summary |
|---|---|
| public PDImageXObject getMask() throws IOException Returns the Mask Image XObject associated with this image, or null if there is none.
| |
| getMetadata | back to summary |
|---|---|
| public PDMetadata getMetadata() Returns the metadata associated with this XObject, or null if there is none.
| |
| getOpaqueImage | back to summary |
|---|---|
| public BufferedImage getOpaqueImage() throws IOException Returns an RGB buffered image containing the opaque image stream without any masks applied. If this Image XObject is a mask then the buffered image will contain the raw mask.
| |
| getOpaqueImage | back to summary |
|---|---|
| public BufferedImage getOpaqueImage(Rectangle region, int subsampling) throws IOException Returns an RGB buffered image containing the opaque image stream without any masks applied. If this Image XObject is a mask then the buffered image will contain the raw mask.
| |
| getOptionalContent | back to summary |
|---|---|
| public PDPropertyList getOptionalContent() This will get the optional content group or optional content membership dictionary.
| |
| getRawImage | back to summary |
|---|---|
| public BufferedImage getRawImage() throws IOException Implements org. Doc from org. Try to get the raw image as AWT buffered image with it's original colorspace. No color conversion is performed.
You could use the returned BufferedImage for draw operations. But this would be very slow as the color conversion
would happen on demand. You rather should use
| |
| getRawRaster | back to summary |
|---|---|
| public WritableRaster getRawRaster() throws IOException Implements org. Doc from org. Return the image data as WritableRaster. You should consult the PDColorSpace returned by
| |
| getSoftMask | back to summary |
|---|---|
| public PDImageXObject getSoftMask() throws IOException Returns the Soft Mask Image XObject associated with this image, or null if there is none.
| |
| getStencilImage | back to summary |
|---|---|
| public BufferedImage getStencilImage(Paint paint) throws IOException Implements org. Doc from org. Returns an ARGB image filled with the given paint and using this image as a mask. The returned images are not cached.
| |
| getStructParent | back to summary |
|---|---|
| public int getStructParent() Returns the key of this XObject in the structural parent tree.
| |
| getSuffix | back to summary |
|---|---|
| public String getSuffix() Implements org. This will get the suffix for this image type, e.g. jpg/png. | |
| getWidth | back to summary |
|---|---|
| public int getWidth() Implements org. Doc from org. Returns the width of this image, or -1 if one has not been set.
| |
| initJPXValues | back to summary |
|---|---|
| private void initJPXValues() | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements org. Doc from org. Returns true if the image has no data.
| |
| isStencil | back to summary |
|---|---|
| public boolean isStencil() Implements org. Doc from org. Returns true if the image is a stencil mask.
| |
| scaleImage | back to summary |
|---|---|
| private static BufferedImage scaleImage(BufferedImage image, int width, int height, int type, boolean interpolate) High-quality image scaling. | |
| setBitsPerComponent | back to summary |
|---|---|
| public void setBitsPerComponent(int bpc) Implements org. Doc from org. Set the number of bits per component.
| |
| setColorSpace | back to summary |
|---|---|
| public void setColorSpace(PDColorSpace cs) Implements org. Doc from org. Sets the color space for this image.
| |
| setDecode | back to summary |
|---|---|
| public void setDecode(COSArray decode) Implements org. Doc from org. Sets the decode array. | |
| setHeight | back to summary |
|---|---|
| public void setHeight(int h) Implements org. Doc from org. Sets the height of the image. This is for internal PDFBox usage and not to set the size of the image on the page.
| |
| setInterpolate | back to summary |
|---|---|
| public void setInterpolate(boolean value) Implements org. Doc from org. Sets the Interpolate flag, true for high-quality image scaling.
| |
| setMetadata | back to summary |
|---|---|
| public void setMetadata(PDMetadata meta) Sets the metadata associated with this XObject, or null if there is none.
| |
| setOptionalContent | back to summary |
|---|---|
| public void setOptionalContent(PDPropertyList oc) Sets the optional content group or optional content membership dictionary.
| |
| setStencil | back to summary |
|---|---|
| public void setStencil(boolean isStencil) Implements org. Doc from org. Sets whether or not the image is a stencil.
This corresponds to the
| |
| setStructParent | back to summary |
|---|---|
| public void setStructParent(int key) Sets the key of this XObject in the structural parent tree.
| |
| setWidth | back to summary |
|---|---|
| public void setWidth(int w) Implements org. Doc from org. Sets the width of the image. This is for internal PDFBox usage and not to set the size of the image on the page.
| |