CmxImage

Inheritance: java.lang.Object, com.aspose.imaging.DisposableObject, com.aspose.imaging.DataStreamSupporter, com.aspose.imaging.Image, com.aspose.imaging.VectorImage, com.aspose.imaging.VectorMultipageImage

All Implemented Interfaces: com.aspose.imaging.fileformats.cmx.ICmxImage

public class CmxImage extends VectorMultipageImage implements ICmxImage

The API for Corel Metafile Exchange (CMX) vector image format with metadata descriptions support is a comprehensive solution for developers working with CMX files. This API allows for the seamless loading of CMX images, extracting metadata such as bits per pixel, object dimensions, and more. With additional functionalities like resizing, rotating, setting palettes, and converting to other formats, this API empowers developers to efficiently manipulate and customize CMX vector images to meet their specific application requirements.

Constructors

ConstructorDescription
CmxImage(StreamContainer streamContainer, LoadOptions loadOptions)Start working with the CmxImage class seamlessly by initializing a new instance with a streamContainer and loadOptions parameters.

Methods

MethodDescription
getFileFormat()Retrieve the file format of the image effortlessly with this user-friendly property.
getBitsPerPixel()Retrieve the bit depth of the image effortlessly with this user-friendly property.
getDefaultPage()Effortlessly retrieve the default page of the image with this intuitive property.
isCached()Determine whether the object’s data is currently cached, eliminating the need for data reading.
getWidthF()Retrieve the width of the object in inches with this intuitive property.
getHeightF()Effortlessly obtain the height of the object, measured in inches, with this user-friendly property.
getDocument()Retrieve the CMX document effortlessly with this intuitive property.
getCmxPage()Effortlessly retrieve the CMX page of the image with this intuitive property.
getPageCount()Retrieve the total page count of the image with this intuitive property.
getPages()Retrieve the pages of the image seamlessly with this intuitive property.
getDefaultOptions(Object[] args)Retrieve the default options effortlessly with this user-friendly method.
cacheData()Cache the data to prevent additional loading from the underlying source DataStreamSupporter with this convenient method.
resize(int newWidth, int newHeight, int resizeType)Effortlessly resize the image to desired dimensions with this intuitive method.
resize(int newWidth, int newHeight, ImageResizeSettings settings)Resizes the image.
rotateFlip(int rotateFlipType)Effortlessly adjust the orientation of the image by rotating, flipping, or applying both operations with this versatile method.
setPalette(IColorPalette palette, boolean updateColors)Customize the color palette of the image with this intuitive method.

Example: The following example shows how to cache all pages of a CMX image.

String dir = "c:\\temp\\";

// Load an image from a CMX file.
com.aspose.imaging.fileformats.cmx.CmxImage image = (com.aspose.imaging.fileformats.cmx.CmxImage) com.aspose.imaging.Image.load(dir + "sample.cmx");
try {
    // This call caches only the default page.
    image.cacheData();

    // Cache all pages so that no additional data loading will be performed from the underlying data stream.
    for (com.aspose.imaging.fileformats.cmx.CmxImagePage page : image.getPages()) {
        page.cacheData();
    }
} finally {
    image.dispose();
}

CmxImage(StreamContainer streamContainer, LoadOptions loadOptions)

public CmxImage(StreamContainer streamContainer, LoadOptions loadOptions)

Start working with the CmxImage class seamlessly by initializing a new instance with a streamContainer and loadOptions parameters. Ideal for developers seeking a convenient way to load CMX images from various data sources while customizing the loading process as needed.

Parameters:

ParameterTypeDescription
streamContainerStreamContainerThe stream container.
loadOptionsLoadOptionsThe load options.

getFileFormat()

public long getFileFormat()

Retrieve the file format of the image effortlessly with this user-friendly property. Ideal for developers seeking to determine the format of their images dynamically, ensuring compatibility and accurate processing in their applications.

Returns: long - The file format FileFormat.Cmx

getBitsPerPixel()

public int getBitsPerPixel()

Retrieve the bit depth of the image effortlessly with this user-friendly property. Ideal for developers seeking to determine the level of detail or color depth present in their images, ensuring accurate processing and manipulation.

Returns: int - The image bits per pixel count.

getDefaultPage()

public Image getDefaultPage()

Effortlessly retrieve the default page of the image with this intuitive property. Ideal for developers seeking quick access to the primary page of their image, ensuring efficient navigation and management.

Returns: Image - the default page.

isCached()

public boolean isCached()

Determine whether the object’s data is currently cached, eliminating the need for data reading. Ideal for developers seeking to optimize performance by leveraging cached data efficiently, ensuring faster access to object information.

Returns: boolean - true if object’s data is cached; otherwise, false.

getWidthF()

public float getWidthF()

Retrieve the width of the object in inches with this intuitive property. Ideal for developers seeking precise measurements of objects in their applications, ensuring accurate layout and presentation.

Returns: float - The object width, in inches.

getHeightF()

public float getHeightF()

Effortlessly obtain the height of the object, measured in inches, with this user-friendly property. Ideal for developers seeking precise dimensional information for effective layout and presentation in their applications.

Returns: float - The object height, in inches.

getDocument()

public final CmxDocument getDocument()

Retrieve the CMX document effortlessly with this intuitive property. Ideal for developers seeking to access or modify CMX images, ensuring flexibility and efficiency in their applications.

Returns: CmxDocument - The CMX document.

getCmxPage()

public final CmxPage getCmxPage()

Effortlessly retrieve the CMX page of the image with this intuitive property. Ideal for developers seeking quick access to individual pages within CMX images, ensuring efficient navigation and management.

Returns: CmxPage - The CMX page.

getPageCount()

public int getPageCount()

Retrieve the total page count of the image with this intuitive property. Ideal for developers seeking to manage multi-page images dynamically, ensuring efficient navigation and manipulation of image content.

Returns: int - the page count.

getPages()

public Image[] getPages()

Retrieve the pages of the image seamlessly with this intuitive property. Ideal for developers seeking to access and manipulate individual pages within multi-page images, ensuring efficient navigation and processing.

Returns: com.aspose.imaging.Image[] - the pages.

Example: The following example shows how to cache all pages of a CMX image.

String dir = "c:\\temp\\";

// Load an image from a CMX file.
com.aspose.imaging.fileformats.cmx.CmxImage image = (com.aspose.imaging.fileformats.cmx.CmxImage) com.aspose.imaging.Image.load(dir + "sample.cmx");
try {
    // This call caches only the default page.
    image.cacheData();

    // Cache all pages so that no additional data loading will be performed from the underlying data stream.
    for (com.aspose.imaging.fileformats.cmx.CmxImagePage page : image.getPages()) {
        page.cacheData();
    }
} finally {
    image.dispose();
}

getDefaultOptions(Object[] args)

public ImageOptionsBase getDefaultOptions(Object[] args)

Retrieve the default options effortlessly with this user-friendly method. Perfect for developers seeking quick access to the default settings or configurations associated with an object, ensuring efficient customization and streamlined workflow.

Parameters:

ParameterTypeDescription
argsjava.lang.Object[]The arguments.

Returns: ImageOptionsBase - Default options

cacheData()

public void cacheData()

Cache the data to prevent additional loading from the underlying source DataStreamSupporter with this convenient method. Ideal for developers seeking to optimize performance by preloading data, ensuring faster access and smoother operation in their applications.

Example: The following example shows how to cache all pages of a CMX image.

String dir = "c:\\temp\\";

// Load an image from a CMX file.
com.aspose.imaging.fileformats.cmx.CmxImage image = (com.aspose.imaging.fileformats.cmx.CmxImage) com.aspose.imaging.Image.load(dir + "sample.cmx");
try {
    // This call caches only the default page.
    image.cacheData();

    // Cache all pages so that no additional data loading will be performed from the underlying data stream.
    for (com.aspose.imaging.fileformats.cmx.CmxImagePage page : image.getPages()) {
        page.cacheData();
    }
} finally {
    image.dispose();
}

resize(int newWidth, int newHeight, int resizeType)

public void resize(int newWidth, int newHeight, int resizeType)

Effortlessly resize the image to desired dimensions with this intuitive method. Perfect for developers seeking to adjust the size of images dynamically, ensuring they fit the layout or requirements of their applications seamlessly.

Parameters:

ParameterTypeDescription
newWidthintThe new width.
newHeightintThe new height.
resizeTypeintThe resize type.

resize(int newWidth, int newHeight, ImageResizeSettings settings)

public void resize(int newWidth, int newHeight, ImageResizeSettings settings)

Resizes the image.

Parameters:

ParameterTypeDescription
newWidthintThe new width.
newHeightintThe new height.
settingsImageResizeSettingsThe resize settings.

rotateFlip(int rotateFlipType)

public void rotateFlip(int rotateFlipType)

Effortlessly adjust the orientation of the image by rotating, flipping, or applying both operations with this versatile method. Perfect for developers seeking to customize image orientation dynamically, ensuring optimal presentation or alignment in their applications.

Parameters:

ParameterTypeDescription
rotateFlipTypeintType of the rotate flip.

setPalette(IColorPalette palette, boolean updateColors)

public void setPalette(IColorPalette palette, boolean updateColors)

Customize the color palette of the image with this intuitive method. Ideal for developers seeking to apply specific color schemes or adjustments dynamically, ensuring precise control over the visual appearance of their images.

Parameters:

ParameterTypeDescription
paletteIColorPaletteThe palette to set.
updateColorsbooleanif set to true colors will be updated according to the new palette; otherwise color indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no corresponding palette entries.