Manipulating CMX Formats
Contents
[
Hide
]
Aspose.Imaging for .NET now supports the CMX (Corel Metafile Exchange) format. CMX files contain vector graphics as well as metadata that describes the image.
Converting CMX to PNG
Using Aspose.Imaging for .NET, developers can convert CMX files to PNG images. This topic explains the approach to load existing CMX file and convert it to PNG.
The following code snippet shows you how to convert CMX files to PNG.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Bmp; | |
using Aspose.Imaging.FileFormats.Eps; | |
using Aspose.Imaging.FileFormats.Eps.Consts; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Psd; | |
using Aspose.Imaging.FileFormats.Svg; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Sources; | |
using System; | |
using System.IO; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
using (Image image = Image.Load(dataDir + "template.cmx")) | |
{ | |
image.Save( | |
dataDir + "result.png", | |
new PngOptions | |
{ | |
VectorRasterizationOptions = | |
new CmxRasterizationOptions() | |
{ | |
Positioning = PositioningTypes.DefinedByDocument, | |
SmoothingMode = SmoothingMode.AntiAlias | |
} | |
}); | |
} | |
File.Delete(dataDir + "result.png"); |
Memory Strategy optimization
Loading and creating of CMX images can be proceeded using memory strategy optimization - ie limiting memory buffer size for operation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Bmp; | |
using Aspose.Imaging.FileFormats.Eps; | |
using Aspose.Imaging.FileFormats.Eps.Consts; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Psd; | |
using Aspose.Imaging.FileFormats.Svg; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Sources; | |
using System; | |
using System.IO; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
using (Image image = Image.Load(dataDir + "template.cmx", new LoadOptions() { BufferSizeHint = 10 })) | |
{ | |
image.Save( | |
dataDir + "result.png", | |
new PngOptions() | |
{ | |
VectorRasterizationOptions = | |
new CmxRasterizationOptions { TextRenderingHint = TextRenderingHint.SingleBitPerPixel, SmoothingMode = SmoothingMode.AntiAlias, Positioning = PositioningTypes.DefinedByDocument } | |
}); | |
} | |
File.Delete(dataDir + "result.png"); |