Class CdrImage

Class CdrImage

Namespace: Aspose.Imaging.FileFormats.Cdr
Assembly: Aspose.Imaging.dll (25.7.0)

The API for CorelDRAW CDR vector image format support is an essential toolkitfor developers working with vector graphics. This API enables theseamless processing of CDR files, allowing for the storage andmanipulation of diverse elements such as text, lines, shapes, images,colors, and effects. With its comprehensive capabilities, developers canefficiently work with vector representations of image contents, ensuringprecision and flexibility in creating and editing CorelDRAW vectorgraphics programmatically.

[JsonObject(MemberSerialization.OptIn)]
   public class CdrImage : VectorMultipageImage, IDisposable, IObjectWithBounds, IObjectWithSizeF, IMultipageImage, ICdrImage
   {
   }

Inheritance

object DisposableObject DataStreamSupporter Image VectorImage VectorMultipageImage CdrImage

Implements

IDisposable , IObjectWithBounds , IObjectWithSizeF , IMultipageImage , ICdrImage

Inherited Members

VectorMultipageImage.CacheData() , VectorMultipageImage.Crop(Rectangle) , VectorMultipageImage.Resize(int, int, ResizeType) , VectorMultipageImage.Rotate(float) , VectorMultipageImage.Resize(int, int, ImageResizeSettings) , VectorMultipageImage.RotateFlip(RotateFlipType) , VectorMultipageImage.RemoveBackground(RemoveBackgroundSettings) , VectorMultipageImage.RemoveBackground() , VectorMultipageImage.SetPalette(IColorPalette, bool) , VectorMultipageImage.GetEmbeddedImages() , VectorMultipageImage.SaveData(Stream) , VectorMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , VectorMultipageImage.ReleaseManagedResources() , VectorMultipageImage.PageCount , VectorMultipageImage.Pages , VectorMultipageImage.DefaultPage , VectorMultipageImage.IsCached , VectorMultipageImage.BitsPerPixel , VectorMultipageImage.Width , VectorMultipageImage.Height , VectorMultipageImage.PageExportingAction , VectorImage.GetDefaultOptions(object[]) , VectorImage.GetEmbeddedImages() , VectorImage.RemoveBackground() , VectorImage.RemoveBackground(RemoveBackgroundSettings) , VectorImage.Resize(int, int, ResizeType) , VectorImage.Resize(int, int, ImageResizeSettings) , VectorImage.RotateFlip(RotateFlipType) , VectorImage.Crop(Rectangle) , VectorImage.Rotate(float) , VectorImage.Modify(RectangleF, float, float, float) , VectorImage.ReleaseManagedResources() , VectorImage.SizeF , VectorImage.WidthF , VectorImage.HeightF , VectorImage.Width , VectorImage.Height , Image.CanLoad(string) , Image.CanLoad(string, LoadOptions) , Image.CanLoad(Stream) , Image.CanLoad(Stream, LoadOptions) , Image.Create(ImageOptionsBase, int, int) , Image.Create(Image[]) , Image.Create(MultipageCreateOptions) , Image.Create(string[], bool) , Image.Create(string[]) , Image.Create(Image[], bool) , Image.GetFileFormat(string) , Image.GetFileFormat(Stream) , Image.GetFittingRectangle(Rectangle, int, int) , Image.GetFittingRectangle(Rectangle, int[], int, int) , Image.Load(string, LoadOptions) , Image.Load(string) , Image.Load(Stream, LoadOptions) , Image.Load(Stream) , Image.GetProportionalWidth(int, int, int) , Image.GetProportionalHeight(int, int, int) , Image.RemoveMetadata() , Image.CanSave(ImageOptionsBase) , Image.Resize(int, int) , Image.Resize(int, int, ResizeType) , Image.Resize(int, int, ImageResizeSettings) , Image.GetDefaultOptions(object[]) , Image.GetOriginalOptions() , Image.ResizeWidthProportionally(int) , Image.ResizeHeightProportionally(int) , Image.ResizeWidthProportionally(int, ResizeType) , Image.ResizeHeightProportionally(int, ResizeType) , Image.ResizeWidthProportionally(int, ImageResizeSettings) , Image.ResizeHeightProportionally(int, ImageResizeSettings) , Image.RotateFlip(RotateFlipType) , Image.Rotate(float) , Image.Crop(Rectangle) , Image.Crop(int, int, int, int) , Image.Save() , Image.Save(string) , Image.Save(string, ImageOptionsBase) , Image.Save(string, ImageOptionsBase, Rectangle) , Image.Save(Stream, ImageOptionsBase) , Image.Save(Stream, ImageOptionsBase, Rectangle) , Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int) , Image.SetPalette(IColorPalette, bool) , Image.UpdateContainer(Image) , Image.GetCanNotSaveMessage(ImageOptionsBase) , Image.GetFitRectangle(Rectangle) , Image.GetImage2Export(ImageOptionsBase, Rectangle, IImageExporter) , Image.GetFitRectangle(Rectangle, int[]) , Image.OnPaletteChanged(IColorPalette, IColorPalette) , Image.OnPaletteChanging(IColorPalette, IColorPalette) , Image.ReleaseManagedResources() , Image.BitsPerPixel , Image.Bounds , Image.Container , Image.Height , Image.Palette , Image.UsePalette , Image.Size , Image.Width , Image.InterruptMonitor , Image.BufferSizeHint , Image.AutoAdjustPalette , Image.HasBackgroundColor , Image.FileFormat , Image.BackgroundColor , DataStreamSupporter.timeout , DataStreamSupporter.CacheData() , DataStreamSupporter.Save() , DataStreamSupporter.Save(Stream) , DataStreamSupporter.Save(string) , DataStreamSupporter.Save(string, bool) , DataStreamSupporter.SaveData(Stream) , DataStreamSupporter.ReleaseManagedResources() , DataStreamSupporter.OnDataStreamContainerChanging(StreamContainer) , DataStreamSupporter.DataStreamContainer , DataStreamSupporter.IsCached , DisposableObject.Dispose() , DisposableObject.ReleaseManagedResources() , DisposableObject.ReleaseUnmanagedResources() , DisposableObject.VerifyNotDisposed() , DisposableObject.Disposed , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

The following example shows how to cache all pages of a CDR image.

string dir = "c:\\temp\\";
   using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = Aspose.Imaging.Image.Load(dir + "sample.cdr"))
   {
       image.CacheData();
       foreach (Aspose.Imaging.FileFormats.Cdr.CdrImagePage page in image.Pages)
       {
           page.CacheData();
       }
   }

Constructors

CdrImage(Stream, LoadOptions)

Start working with the Aspose.Imaging.FileFormats.Cdr.CdrImage class effortlessly byinitializing a new instance with a stream and loadOptions parameters.Ideal for developers seeking a convenient way to load CDR images fromvarious data sources while customizing the loading process as needed.

public CdrImage(Stream stream, LoadOptions loadOptions)
   {
   }

Parameters

stream Stream

The stream.

loadOptions LoadOptions

The load options.

Exceptions

IndexOutOfRangeException

CDR document contains no pages.

Properties

BitsPerPixel

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 presentin their images, ensuring accurate processing and manipulation.

public override int BitsPerPixel
   {
      get;
   }

Property Value

int

CdrDocument

Effortlessly retrieve or update the CDR document using this intuitive property.Ideal for developers seeking to access or modify the CDR document, ensuringflexibility and efficiency in their applications.

public CdrDocument CdrDocument get; {}

Property Value

CdrDocument

DefaultPage

Retrieve the default page of the image with ease using this user-friendly property.Perfect for developers seeking quick access to the primary page of their image,ensuring efficient navigation and management.

public override Image DefaultPage
    {
        get;
    }
In this case, I have only adjusted the indentation to follow standard C# conventions.

Property Value

Image

FileFormat

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

public override FileFormat
    {
        get;
    }

Property Value

FileFormat

Height

Gets the image height.

public override int Height
   {
      get;
   }

Property Value

int

IsCached

Effortlessly determine whether the object’s data is currently cached,eliminating the need for data reading. Ideal for developers seekingto optimize performance by leveraging cached data efficiently, ensuringfaster access to object information.

public override bool IsCached
   {
      get;
   }

Property Value

bool

PageCount

Effortlessly retrieve or update the total page count of the image with thisintuitive property. Ideal for developers seeking to manage multi-page imagesdynamically, ensuring efficient navigation and manipulation of image content.

public override int PageCount
   {
      get;
   }

Property Value

int

Pages

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

public override Image[] Pages
{
    get;
}

Property Value

Image []

Examples

The following example shows how to cache all pages of a CDR image.

string dir = "c:\\temp\\";
   using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = Aspose.Imaging.Image.Load(dir + "sample.cdr"))
   {
       image.CacheData();
       foreach (Aspose.Imaging.FileFormats.Cdr.CdrImagePage page in image.Pages)
       {
           page.CacheData();
       }
   }

The following example shows how to export a single page of CDR document to PDF.

int pageNumber = 0;
   string dir = "c:\\aspose.imaging\\issues\\net\\3635\\testdata\\3570";
   string inputCdrFileName = System.IO.Path.Combine(dir, "tiger.cdr");
   string outputPdfFileName = System.IO.Path.Combine(dir, "tiger.cdr.page" + pageNumber + ".pdf");
   using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = (Aspose.Imaging.FileFormats.Cdr.CdrImage) Aspose.Imaging.Image.Load(inputCdrFileName))
   {
       Aspose.Imaging.FileFormats.Cdr.CdrImagePage imagePage = (Aspose.Imaging.FileFormats.Cdr.CdrImagePage) image.Pages[pageNumber];
       Aspose.Imaging.ImageOptions.PdfOptions pdfOptions = new Aspose.Imaging.ImageOptions.PdfOptions();
       Aspose.Imaging.ImageOptions.CdrRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.CdrRasterizationOptions()
       {
           TextRenderingHint = Aspose.Imaging.TextRenderingHint.SingleBitPerPixel,
           SmoothingMode = Aspose.Imaging.SmoothingMode.None
       };
       pdfOptions.VectorRasterizationOptions = rasterizationOptions;
       pdfOptions.VectorRasterizationOptions.PageWidth = imagePage.Width;
       pdfOptions.VectorRasterizationOptions.PageHeight = imagePage.Height;
       imagePage.Save(outputPdfFileName, pdfOptions);
   }

Width

Gets the image width.

public override
    int Width
    {
        get;
    }

Property Value

int

Methods

CacheData()

Effortlessly cache the data to prevent additional loading from the underlying sourcewith this user-friendly method. Ideal for developers seeking to optimize performanceby preloading data, ensuring faster access and smoother operation in their applications.Aspose.Imaging.DataStreamSupporter.DataStreamContainer.

public override void CacheData()
   {
   }
I have properly indented and added an empty line to improve readability, while keeping the original logic intact.

Examples

The following example shows how to cache all pages of a CDR image.

string dir = "c:\\temp\\";
   using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = Aspose.Imaging.Image.Load(dir + "sample.cdr"))
   {
       image.CacheData();
       foreach (Aspose.Imaging.FileFormats.Cdr.CdrImagePage page in image.Pages)
       {
           page.CacheData();
       }
   }

ReleaseManagedResources()

Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.

protected override void ReleaseManagedResources()
   {
      base.ReleaseManagedResources();
   }

SaveData(Stream)

Saves the data.

protected override void SaveData(Stream stream)
   {
   }

Parameters

stream Stream

The stream to save data to.

Exceptions

NotImplementedException

NotImplementedException

SetPalette(IColorPalette, bool)

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

public override void
    SetPalette(IColorPalette palette, bool updateColors)
{
}

Parameters

palette IColorPalette

The palette to set.

updateColors bool

if set to ’true’ colors will be updated according to the new palette; otherwise colorindexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have nocorresponding palette entries.

Exceptions

NotImplementedException

NotImplementedException

See Also

Image , ICdrImage

 English