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
| Name | Type | Access | Description |
|---|---|---|---|
width | int | Read | Returns the image width in pixels (/Width). |
height | int | Read | Returns the image height in pixels (/Height). |
bitsPerComponent | int | Read | Returns the bits per component (/BitsPerComponent). |
name | String | Read | Returns the resource name of this image (e.g., “Im1”). |
colorSpace | ColorSpaceBase | Read | Returns the color space of this image. |
imageMask | boolean | Read | Returns whether this is an image mask (1-bit stencil). |
decodedData | byte[] | Read | Returns the decoded image data (raw pixel bytes after filter decompression). |
encodedData | byte[] | Read | Returns the raw encoded stream data (e.g., raw JPEG bytes for DCTDecode). |
cOSStream | COSStream | Read | Returns the underlying COS stream. |
Methods
| Signature | Description |
|---|---|
XImage(stream: COSStream, name: String, parser: PDFParser) | Creates an XImage from an image XObject stream. |
getWidth() → int | Returns the image width in pixels (/Width). |
getHeight() → int | Returns the image height in pixels (/Height). |
getBitsPerComponent() → int | Returns the bits per component (/BitsPerComponent). |
getName() → String | Returns 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() → ColorSpaceBase | Returns the color space of this image. |
isImageMask() → boolean | Returns 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() → BufferedImage | Converts 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() → COSStream | Returns the underlying COS stream. |