Interface PDImage
-
- All Superinterfaces:
COSObjectable
- All Known Implementing Classes:
PDImageXObject,PDInlineImage
public interface PDImage extends COSObjectable
An image in a PDF document.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStreamcreateInputStream()Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject.InputStreamcreateInputStream(List<String> stopFilters)Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject.intgetBitsPerComponent()Returns bits per component of this image, or -1 if one has not been set.PDColorSpacegetColorSpace()Returns the image's color space.COSArraygetDecode()Returns the decode array.intgetHeight()Returns height of this image, or -1 if one has not been set.android.graphics.BitmapgetImage()Returns the content of this image as a Bitmap with ARGB_888.booleangetInterpolate()Returns true if the image should be interpolated when rendered.android.graphics.BitmapgetStencilImage(android.graphics.Paint paint)Returns an ARGB image filled with the given paint and using this image as a mask.PDStreamgetStream()Returns a stream containing this image's data.StringgetSuffix()Returns the suffix for this image type, e.g.intgetWidth()Returns the width of this image, or -1 if one has not been set.booleanisEmpty()Returns true if the image has no data.booleanisStencil()Returns true if the image is a stencil mask.voidsetBitsPerComponent(int bitsPerComponent)Set the number of bits per component.voidsetColorSpace(PDColorSpace colorSpace)Sets the color space for this image.voidsetDecode(COSArray decode)Sets the decode array.voidsetHeight(int height)Sets the height of the image.voidsetInterpolate(boolean value)Sets the Interpolate flag, true for high-quality image scaling.voidsetStencil(boolean isStencil)Sets whether or not the image is a stencil.voidsetWidth(int width)Sets the width of the image.-
Methods inherited from interface com.tom_roush.pdfbox.pdmodel.common.COSObjectable
getCOSObject
-
-
-
-
Method Detail
-
getImage
android.graphics.Bitmap getImage() throws IOExceptionReturns the content of this image as a Bitmap with ARGB_888. The size of the returned image is the larger of the size of the image itself or its mask.- Returns:
- content of this image as a buffered image.
- Throws:
IOException
-
getStencilImage
android.graphics.Bitmap getStencilImage(android.graphics.Paint paint) throws IOExceptionReturns an ARGB image filled with the given paint and using this image as a mask.- Parameters:
paint- the paint to fill the visible portions of the image with- Returns:
- a masked image filled with the given paint
- Throws:
IOException- if the image cannot be readIllegalStateException- if the image is not a stencil.
-
getStream
PDStream getStream() throws IOException
Returns a stream containing this image's data. Null for inline images.- Throws:
IOException- if the stream could not be read.
-
createInputStream
InputStream createInputStream() throws IOException
Returns an InputStream containing the image data, irrespective of whether this is an inline image or an image XObject.- Returns:
- Decoded stream\
- Throws:
IOException- if the data could not be read.
-
createInputStream
InputStream createInputStream(List<String> stopFilters) throws IOException
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.- Returns:
- Decoded stream
- Throws:
IOException- if the data could not be read.
-
isEmpty
boolean isEmpty()
Returns true if the image has no data.
-
isStencil
boolean isStencil()
Returns true if the image is a stencil mask.
-
setStencil
void setStencil(boolean isStencil)
Sets whether or not the image is a stencil. This corresponds to theImageMaskentry in the image stream's dictionary.- Parameters:
isStencil- True to make the image a stencil.
-
getBitsPerComponent
int getBitsPerComponent()
Returns bits per component of this image, or -1 if one has not been set.
-
setBitsPerComponent
void setBitsPerComponent(int bitsPerComponent)
Set the number of bits per component.- Parameters:
bitsPerComponent- The number of bits per component.
-
getColorSpace
PDColorSpace getColorSpace() throws IOException
Returns the image's color space.- Throws:
IOException- If there is an error getting the color space.
-
setColorSpace
void setColorSpace(PDColorSpace colorSpace)
Sets the color space for this image.- Parameters:
colorSpace- The color space for this image.
-
getHeight
int getHeight()
Returns height of this image, or -1 if one has not been set.
-
setHeight
void setHeight(int height)
Sets the height of the image.- Parameters:
height- The height of the image.
-
getWidth
int getWidth()
Returns the width of this image, or -1 if one has not been set.
-
setWidth
void setWidth(int width)
Sets the width of the image.- Parameters:
width- The width of the image.
-
setDecode
void setDecode(COSArray decode)
Sets the decode array.- Parameters:
decode- the new decode array.
-
getDecode
COSArray getDecode()
Returns the decode array.
-
getInterpolate
boolean getInterpolate()
Returns true if the image should be interpolated when rendered.
-
setInterpolate
void setInterpolate(boolean value)
Sets the Interpolate flag, true for high-quality image scaling.
-
getSuffix
String getSuffix()
Returns the suffix for this image type, e.g. "jpg"
-
-