public final class XImage extends Object
Class representing image X-Object.
Modifier and Type | Class and Description |
---|---|
static class |
XImage.RawParameters
Class representing image raw XImage parameters.
|
Constructor and Description |
---|
XImage(com.aspose.pdf.engine.data.IPdfDataStream image)
for internal usage only
|
Modifier and Type | Method and Description |
---|---|
void |
addStencilMask(InputStream maskStream)
Adds a stencil mask to the XImage.
|
boolean |
containsTransparency()
If the image contains transparency than return true; otherwise, false.
|
void |
delete()
Deletes image from the parent collection.
|
static ColorType |
detectColorType(BufferedImage bmp)
Returns color type of image.
|
List<String> |
getAlternativeText(Page page)
Returns a list of strings with Alternative Text for an XImage.
|
ColorType |
getColorType()
Returns color type of image.
|
com.aspose.pdf.engine.data.IPdfDataStream |
getEngineImg()
IPdfImage object which decribes image.
|
ImageFilterType |
getFilterType()
Gets image filter type.
|
BufferedImage |
getGrayscaled()
Gets grayscaled version of image.
|
int |
getHeight()
Gets height of the image.
|
com.aspose.ms.System.Drawing.Bitmap |
getImage()
For internal use only
|
Metadata |
getMetadata()
Metadata of the image.
|
String |
getName()
Gets image name.
|
String |
getNameInCollection()
Returns the name of the image in its collection.
|
byte[] |
getRawBytes()
Returns raw bytes for the image without decoding.
|
byte[] |
getRawImageData()
Retrieves the raw image data from the source image.
|
XImage.RawParameters |
getRawParameters()
Gets raw image parameters
|
int |
getWidth()
Gets width of the image.
|
static boolean |
isImage(com.aspose.pdf.engine.data.IPdfPrimitive primitive)
Returns true if the primitive is an image.
|
boolean |
isImageMask()
Gets a flag indicating whether the image shall be treated as an image mask (see 8.9.6, "Masked Images").
|
boolean |
isTheSameObject(XImage image)
Returns true if both images references to the same object.
|
void |
rename(String name)
Renames image and replaces all references to the image with the new name
|
void |
replace(InputStream image)
Replaces image onto stream specified in
image . |
void |
save(OutputStream stream)
Saves image data into stream as JPEG image.
|
void |
save(OutputStream stream,
float xDpi,
float yDpi)
Saves image into stream with requested format.
|
void |
save(OutputStream stream,
ImageType format)
Saves image into stream with requested format.
|
void |
save(OutputStream stream,
ImageType format,
int resolution)
Saves image into stream with requested format.
|
void |
save(OutputStream stream,
int resolution)
Saves image into stream with requested format with specified resolution.
|
void |
saveInternal(com.aspose.ms.System.IO.Stream stream,
ImageType format)
Saves image into stream with requested format.
|
void |
saveInternal(com.aspose.ms.System.IO.Stream stream,
ImageType format,
int resolution) |
void |
saveInternal(com.aspose.ms.System.IO.Stream stream,
int resolution)
Saves image data into stream as JPEG image with specified resolution.
|
void |
setName(String value)
Sets image name.
|
InputStream |
toStream()
Returns the original image stream.
|
String |
toString()
Returns a string representation XImage object properties.
|
boolean |
trySetAlternativeText(String alternativeText,
Page page)
Sets alternative text for an XImage on the page.
|
public XImage(com.aspose.pdf.engine.data.IPdfDataStream image)
image
- internal instancepublic boolean containsTransparency()
If the image contains transparency than return true; otherwise, false.
public final ImageFilterType getFilterType()
Gets image filter type.
public BufferedImage getGrayscaled()
Gets grayscaled version of image.
public void delete()
Deletes image from the parent collection.
public void replace(InputStream image)
Replaces image onto stream specified in image
.
image
- Stream with image data.public com.aspose.pdf.engine.data.IPdfDataStream getEngineImg()
IPdfImage object which decribes image. Internal only
public int getWidth()
Gets width of the image.
public int getHeight()
Gets height of the image.
public String getName()
Gets image name. Please note that if you change name of the image which has references in page contents, document may became incorrect. Please use XImage.Rename method in this case.
public void setName(String value)
Sets image name. Please note that if you change name of the image which has references in page contents, document may became incorrect. Please use XImage.Rename method in this case.
value
- String valuepublic final void rename(String name)
Renames image and replaces all references to the image with the new name
name
- New image name.public final boolean isImageMask()
Gets a flag indicating whether the image shall be treated as an image mask (see 8.9.6, "Masked Images"). If this flag is true, the value of BitsPerComponent shall be 1 and Mask and ColorSpace shall not be specified; unmasked areas shall bepainted using the current nonstroking colour. Default value: false.
Value: True is the image is image mask.public void save(OutputStream stream)
Saves image data into stream as JPEG image.
stream
- Stream where image data will be saved.public void save(OutputStream stream, float xDpi, float yDpi)
Saves image into stream with requested format.
stream
- OutputStream where image will be savedxDpi
- Image horizontal resolutionyDpi
- Image vertical resolutionpublic void saveInternal(com.aspose.ms.System.IO.Stream stream, ImageType format)
Saves image into stream with requested format.
stream
- Stream where image will be savedformat
- Format which will be used for image enconding. ImageFormat
public void save(OutputStream stream, ImageType format)
Saves image into stream with requested format.
stream
- Stream where image will be savedformat
- Format which will be used for image enconding.ImageType
public com.aspose.ms.System.Drawing.Bitmap getImage()
public final byte[] getRawImageData()
Retrieves the raw image data from the source image.
byte[]
containing the original image data.public final void addStencilMask(InputStream maskStream)
Adds a stencil mask to the XImage.
maskStream
- Stencil mask bitmap stream.public void saveInternal(com.aspose.ms.System.IO.Stream stream, int resolution)
Saves image data into stream as JPEG image with specified resolution.
stream
- Stream where image data will be saved.resolution
- Image resolutionpublic void save(OutputStream stream, int resolution)
Saves image into stream with requested format with specified resolution.
stream
- Stream where image will be savedresolution
- Image resolutionpublic void saveInternal(com.aspose.ms.System.IO.Stream stream, ImageType format, int resolution)
public void save(OutputStream stream, ImageType format, int resolution)
Saves image into stream with requested format.
stream
- Stream where image will be savedformat
- Format which will be used for image enconding.resolution
- Image resolutionImageType
public static boolean isImage(com.aspose.pdf.engine.data.IPdfPrimitive primitive)
Returns true if the primitive is an image.
primitive
- IPdfPrimitivepublic ColorType getColorType()
Returns color type of image.
public static ColorType detectColorType(BufferedImage bmp)
Returns color type of image.
bmp
- Image.ColorType
public boolean isTheSameObject(XImage image)
Returns true if both images references to the same object.
image
- Image to be compared with "this" image.public String getNameInCollection()
Returns the name of the image in its collection.
public XImage.RawParameters getRawParameters()
public String toString()
public byte[] getRawBytes()
public InputStream toStream()
Returns the original image stream.
public final List<String> getAlternativeText(Page page)
Returns a list of strings with Alternative Text for an XImage.
page
- The page where XImage is located.public final boolean trySetAlternativeText(String alternativeText, Page page)
Sets alternative text for an XImage on the page.
alternativeText
- The alternative text to be specified.page
- Page where XImage is located.public final Metadata getMetadata()
Metadata of the image.
Copyright © 2025 Aspose. All Rights Reserved.