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

针对 Corel Metafile Exchange (CMX) 矢量图像格式并支持元数据描述的 API 是为使用 CMX 文件的开发者提供的综合解决方案。该 API 可实现无缝加载 CMX 图像,提取诸如每像素位数、对象尺寸等元数据。通过提供图像缩放、旋转、调色板设置以及转换为其他格式等附加功能,该 API 使开发者能够高效地操作和定制 CMX 矢量图像,以满足其特定的应用需求。

构造函数

构造函数描述
CmxImage(StreamContainer streamContainer, LoadOptions loadOptions)通过使用 streamContainer 和 loadOptions 参数初始化新实例,即可无缝开始使用 CmxImage 类。

方法

方法描述
getFileFormat()使用此用户友好的属性,轻松获取图像的文件格式。
getBitsPerPixel()使用此用户友好的属性,轻松获取图像的位深度。
getDefaultPage()使用此直观属性,轻松检索图像的默认页面。
isCached()确定对象的数据当前是否已缓存,从而消除读取数据的需求。
getWidthF()使用此直观属性,获取对象以英寸为单位的宽度。
getHeightF()使用此用户友好的属性,轻松获取对象以英寸为单位的高度。
getDocument()使用此直观属性,轻松获取 CMX 文档。
getCmxPage()使用此直观属性,轻松获取图像的 CMX 页面。
getPageCount()使用此直观属性,获取图像的总页数。
getPages()使用此直观属性,顺畅获取图像的页面。
cacheData()使用此便捷方法缓存数据,以防止从底层源 DataStreamSupporter 进行额外加载。
setPalette(IColorPalette palette, boolean updateColors)使用此直观方法自定义图像的颜色调色板。

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

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

// 从 CMX 文件加载图像。
com.aspose.imaging.fileformats.cmx.CmxImage image = (com.aspose.imaging.fileformats.cmx.CmxImage) com.aspose.imaging.Image.load(dir + "sample.cmx");
try {
    // 此调用仅缓存默认页面。
    image.cacheData();

    // 缓存所有页面,以防止从底层数据流进行额外的数据加载。
    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)

通过使用 streamContainer 和 loadOptions 参数初始化新实例,您可以无缝开始使用 CmxImage 类。此方式非常适合希望以便捷方式从各种数据源加载 CMX 图像并根据需要自定义加载过程的开发者。

Parameters:

参数类型描述
streamContainerStreamContainer流容器。
loadOptionsLoadOptions加载选项。

getFileFormat()

public long getFileFormat()

使用此用户友好的属性,轻松获取图像的文件格式。该属性非常适合希望动态确定图像格式、确保兼容性并在应用程序中进行准确处理的开发者。

Returns: long - 文件格式 FileFormat.Cmx

getBitsPerPixel()

public int getBitsPerPixel()

使用此用户友好的属性,轻松获取图像的位深度。该属性非常适合希望确定图像细节级别或颜色深度、确保准确处理和操作的开发者。

Returns: int - 图像每像素位数。

getDefaultPage()

public Image getDefaultPage()

使用此直观属性,轻松检索图像的默认页面。适用于希望快速访问图像主页面的开发者,确保高效的导航和管理。

Returns: Image - the default page.

isCached()

public boolean isCached()

确定对象的数据是否已缓存,从而消除读取数据的需求。适用于希望通过高效利用缓存数据来优化性能的开发者,确保更快访问对象信息。

Returns: 布尔值 - 如果对象的数据已缓存则为 true;否则为 false

getWidthF()

public float getWidthF()

使用此直观属性检索对象的宽度(英寸)。适用于在应用程序中需要精确测量对象的开发者,确保布局和呈现的准确性。

Returns: float - 对象宽度,单位为英寸。

getHeightF()

public float getHeightF()

使用此用户友好属性,轻松获取对象的高度(英寸)。适用于在应用程序中需要精确尺寸信息以实现有效布局和呈现的开发者。

Returns: float - 对象高度,单位为英寸。

getDocument()

public final CmxDocument getDocument()

使用此直观属性,轻松检索 CMX 文档。适用于希望访问或修改 CMX 图像的开发者,确保应用程序的灵活性和效率。

Returns: CmxDocument - The CMX document.

getCmxPage()

public final CmxPage getCmxPage()

使用此直观属性,轻松检索图像的 CMX 页面。适用于希望快速访问 CMX 图像中各个页面的开发者,确保高效的导航和管理。

Returns: CmxPage - The CMX page.

getPageCount()

public int getPageCount()

使用此直观属性检索图像的总页数。适用于希望动态管理多页图像的开发者,确保对图像内容的高效导航和操作。

Returns: int - 页数。

getPages()

public Image[] getPages()

使用此直观属性无缝检索图像的各页。适用于希望访问和操作多页图像中单个页面的开发者,确保高效的导航和处理。

Returns: com.aspose.imaging.Image[] - 页面。

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

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

// 从 CMX 文件加载图像。
com.aspose.imaging.fileformats.cmx.CmxImage image = (com.aspose.imaging.fileformats.cmx.CmxImage) com.aspose.imaging.Image.load(dir + "sample.cmx");
try {
    // 此调用仅缓存默认页面。
    image.cacheData();

    // 缓存所有页面,以防止从底层数据流进行额外的数据加载。
    for (com.aspose.imaging.fileformats.cmx.CmxImagePage page : image.getPages()) {
        page.cacheData();
    }
} finally {
    image.dispose();
}

cacheData()

public void cacheData()

使用此便捷方法缓存数据,以防止从底层来源 DataStreamSupporter 进行额外加载。适用于希望通过预加载数据来优化性能的开发者,确保在应用程序中更快的访问和更流畅的运行。

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

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

// 从 CMX 文件加载图像。
com.aspose.imaging.fileformats.cmx.CmxImage image = (com.aspose.imaging.fileformats.cmx.CmxImage) com.aspose.imaging.Image.load(dir + "sample.cmx");
try {
    // 此调用仅缓存默认页面。
    image.cacheData();

    // 缓存所有页面,以防止从底层数据流进行额外的数据加载。
    for (com.aspose.imaging.fileformats.cmx.CmxImagePage page : image.getPages()) {
        page.cacheData();
    }
} finally {
    image.dispose();
}

setPalette(IColorPalette palette, boolean updateColors)

public void setPalette(IColorPalette palette, boolean updateColors)

使用此直观方法自定义图像的颜色调色板。适用于希望动态应用特定配色方案或调整的开发者,确保对图像视觉外观的精确控制。

Parameters:

参数类型描述
paletteIColorPalette要设置的调色板。
updateColorsboolean如果设置为 true,颜色将根据新调色板进行更新;否则颜色索引保持不变。请注意,如果某些索引没有对应的调色板条目,未更改的索引可能在加载时导致图像崩溃。