Convert CDR to PNG in C#
Contents
[
Hide
]
Using C# Image Processing Library Aspose.Imaging we can convert CDR image to PNG.
The following code snippet shows you how to convert CDR 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.ImageOptions; | |
using System.IO; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = (Aspose.Imaging.FileFormats.Cdr.CdrImage)Image.Load(dataDir + "template.cdr")) | |
{ | |
PngOptions options = new Aspose.Imaging.ImageOptions.PngOptions(); | |
options.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha; | |
// Set rasterization options for fileformat | |
options.VectorRasterizationOptions = (Aspose.Imaging.ImageOptions.VectorRasterizationOptions) | |
image.GetDefaultOptions(new object[] { Color.White, image.Width, image.Height }); | |
options.VectorRasterizationOptions.TextRenderingHint = TextRenderingHint.SingleBitPerPixel; | |
options.VectorRasterizationOptions.SmoothingMode = SmoothingMode.None; | |
image.Save(dataDir + "result.png", options); | |
} | |
File.Delete(dataDir + "result.png"); |