XImage

Overview

XImage is a class in Aspose.Pdf FOSS for Java.

Represents an image XObject in a PDF document (ISO 32000-1:2008, §8.9, Table 89).

Properties

NameTypeAccessDescription
widthintReadReturns the image width in pixels (/Width).
heightintReadReturns the image height in pixels (/Height).
bitsPerComponentintReadReturns the bits per component (/BitsPerComponent).
nameStringReadReturns the resource name of this image (e.g., “Im1”).
colorSpaceColorSpaceBaseReadReturns the color space of this image.
imageMaskbooleanReadReturns whether this is an image mask (1-bit stencil).
decodedDatabyte[]ReadReturns the decoded image data (raw pixel bytes after filter decompression).
encodedDatabyte[]ReadReturns the raw encoded stream data (e.g., raw JPEG bytes for DCTDecode).
cOSStreamCOSStreamReadReturns the underlying COS stream.

Methods

SignatureDescription
XImage(stream: COSStream, name: String, parser: PDFParser)Creates an XImage from an image XObject stream.
getWidth()intReturns the image width in pixels (/Width).
getHeight()intReturns the image height in pixels (/Height).
getBitsPerComponent()intReturns the bits per component (/BitsPerComponent).
getName()StringReturns the resource name of this image (e.g., “Im1”).
setName(newName: String)Sets the name of this image resource, updating both the Java field
and the key in the parent /XObject dictionary (if known).
getColorSpace()ColorSpaceBaseReturns the color space of this image.
isImageMask()booleanReturns whether this is an image mask (1-bit stencil).
getDecodedData()byte[]Returns the decoded image data (raw pixel bytes after filter decompression).
getEncodedData()byte[]Returns the raw encoded stream data (e.g., raw JPEG bytes for DCTDecode).
save(output: OutputStream)Saves the image to an output stream.
toBufferedImage()BufferedImageConverts this image to a {@link BufferedImage}.
delete()Deletes this image from the parent XObject dictionary.
replace(newImageStream: InputStream)Replaces this image with data from an input stream.
getCOSStream()COSStreamReturns the underlying COS stream.

See Also