XImage

Inheritance: java.lang.Object

public final class XImage

Class representing image X-Object.

Constructors

ConstructorDescription
XImage(IPdfDataStream image)for internal usage only

Methods

MethodDescription
containsTransparency()If the image contains transparancy than return true; otherwise, false.
getFilterType()Gets image filter type.
getGrayscaled()Gets grayscaled version of image.
delete()Deletes image from the parent collection.
replace(InputStream image)Replaces image onto stream specified in image .
getEngineImg()IPdfImage object which decribes image.
getWidth()Gets width of the image.
getHeight()Gets height of the image.
getName()Gets image name.
setName(String value)Sets image name.
rename(String name)Renames image and replaces all references to the image with the new name
save(OutputStream stream)Saves image data into stream as JPEG image.
save(OutputStream stream, float xDpi, float yDpi)Saves image into stream with requested format.
saveInternal(System.IO.Stream stream, ImageType format)Saves image into stream with requested format.
save(OutputStream stream, ImageType format)Saves image into stream with requested format.
getImage()For internal use only
saveInternal(System.IO.Stream stream, int resolution)Saves image data into stream as JPEG image with specified resolution.
save(OutputStream stream, int resolution)Saves image into stream with requested format with specified resolution.
saveInternal(System.IO.Stream stream, ImageType format, int resolution)
save(OutputStream stream, ImageType format, int resolution)Saves image into stream with requested format.
isImage(IPdfPrimitive primitive)Returns true if the primitive is an image.
getColorType()Returns color type of image.
detectColorType(BufferedImage bmp)Returns color type of image.
isTheSameObject(XImage image)Returns true if both images references to the same object.
getNameInCollection()Returns name of the image in its collection.
getRawParameters()Gets raw image parameters
toString()Returns a string representation XImage object properties.
getRawBytes()Returns raw bytes for the image without decoding.
toStream()Returns the original image stream.
getMetadata()Metadata of the image.

XImage(IPdfDataStream image)

public XImage(IPdfDataStream image)

for internal usage only

Parameters:

ParameterTypeDescription
imageIPdfDataStreaminternal instance

containsTransparency()

public boolean containsTransparency()

If the image contains transparancy than return true; otherwise, false.

Returns: boolean - boolean value

getFilterType()

public final int getFilterType()

Gets image filter type.

Returns: int - ImageFilterType element

getGrayscaled()

public BufferedImage getGrayscaled()

Gets grayscaled version of image.

Returns: java.awt.image.BufferedImage - BufferedImage

delete()

public void delete()

Deletes image from the parent collection.

replace(InputStream image)

public void replace(InputStream image)

Replaces image onto stream specified in image .

*

Parameters:

ParameterTypeDescription
imagejava.io.InputStreamStream with image data.

getEngineImg()

public IPdfDataStream getEngineImg()

IPdfImage object which decribes image. Internal only

Returns: IPdfDataStream - IPdfDataStream

getWidth()

public int getWidth()

Gets width of the image.

Returns: int - int value

getHeight()

public int getHeight()

Gets height of the image.

Returns: int - int value

getName()

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.

Returns: java.lang.String - String

setName(String value)

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.

Parameters:

ParameterTypeDescription
valuejava.lang.StringString value

rename(String name)

public final void rename(String name)

Renames image and replaces all references to the image with the new name

Parameters:

ParameterTypeDescription
namejava.lang.StringNew image name.

save(OutputStream stream)

public void save(OutputStream stream)

Saves image data into stream as JPEG image.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamStream where image data will be saved.

save(OutputStream stream, float xDpi, float yDpi)

public void save(OutputStream stream, float xDpi, float yDpi)

Saves image into stream with requested format.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamOutputStream where image will be saved
xDpifloatImage horizontal resolution
yDpifloatImage vertical resolution

saveInternal(System.IO.Stream stream, ImageType format)

public void saveInternal(System.IO.Stream stream, ImageType format)

Saves image into stream with requested format.

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.StreamStream where image will be saved
formatImageTypeFormat which will be used for image enconding. ImageFormat

save(OutputStream stream, ImageType format)

public void save(OutputStream stream, ImageType format)

Saves image into stream with requested format.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamStream where image will be saved
formatImageTypeFormat which will be used for image enconding.

getImage()

public System.Drawing.Bitmap getImage()

For internal use only

Returns: com.aspose.ms.System.Drawing.Bitmap - Image

saveInternal(System.IO.Stream stream, int resolution)

public void saveInternal(System.IO.Stream stream, int resolution)

Saves image data into stream as JPEG image with specified resolution.

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.StreamStream where image data will be saved.
resolutionintImage resolution

save(OutputStream stream, int resolution)

public void save(OutputStream stream, int resolution)

Saves image into stream with requested format with specified resolution.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamStream where image will be saved
resolutionintImage resolution

saveInternal(System.IO.Stream stream, ImageType format, int resolution)

public void saveInternal(System.IO.Stream stream, ImageType format, int resolution)

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.Stream
formatImageType
resolutionint

save(OutputStream stream, ImageType format, int resolution)

public void save(OutputStream stream, ImageType format, int resolution)

Saves image into stream with requested format.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamStream where image will be saved
formatImageTypeFormat which will be used for image enconding.
resolutionintImage resolution

isImage(IPdfPrimitive primitive)

public static boolean isImage(IPdfPrimitive primitive)

Returns true if the primitive is an image.

Parameters:

ParameterTypeDescription
primitiveIPdfPrimitiveIPdfPrimitive

Returns: boolean - boolean

getColorType()

public int getColorType()

Returns color type of image.

Returns: int - The color type value.

detectColorType(BufferedImage bmp)

public static int detectColorType(BufferedImage bmp)

Returns color type of image.

Parameters:

ParameterTypeDescription
bmpjava.awt.image.BufferedImageImage.

Returns: int - Color type.

isTheSameObject(XImage image)

public boolean isTheSameObject(XImage image)

Returns true if both images references to the same object.

Parameters:

ParameterTypeDescription
imageXImageImage to be compared with “this” image.

Returns: boolean - Boolean value which is true if images references to the same object.

getNameInCollection()

public String getNameInCollection()

Returns name of the image in its collection.

Returns: java.lang.String - Image key (name).

getRawParameters()

public XImage.RawParameters getRawParameters()

Gets raw image parameters

Returns: RawParameters - RawParameters instance

toString()

public String toString()

Returns a string representation XImage object properties.

Returns: java.lang.String - String instance

getRawBytes()

public byte[] getRawBytes()

Returns raw bytes for the image without decoding.

Returns: byte[] - byte array

toStream()

public InputStream toStream()

Returns the original image stream.

Returns: java.io.InputStream - The original image stream.

getMetadata()

public final Metadata getMetadata()

Metadata of the image.

Returns: Metadata - Metadata instance