Class CdrImage
Namespace: Aspose.Imaging.FileFormats.Cdr
Assembly: Aspose.Imaging.dll (25.2.0)
The API for CorelDRAW CDR vector image format support is an essential toolkit for developers working with vector graphics. This API enables the seamless processing of CDR files, allowing for the storage and manipulation of diverse elements such as text, lines, shapes, images, colors, and effects. With its comprehensive capabilities, developers can efficiently work with vector representations of image contents, ensuring precision and flexibility in creating and editing CorelDRAW vector graphics 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.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.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.```csharp [C#]
string dir = "c:\\temp\\";
// Load an image from a CDR file.
using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = (Aspose.Imaging.FileFormats.Cdr.CdrImage)Aspose.Imaging.Image.Load(dir + "sample.cdr"))
{
// 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.
foreach (Aspose.Imaging.FileFormats.Cdr.CdrImagePage page in image.Pages)
{
page.CacheData();
}
}
## Constructors
### <a id="Aspose_Imaging_FileFormats_Cdr_CdrImage__ctor_System_IO_Stream_Aspose_Imaging_LoadOptions_"></a> CdrImage\(Stream, LoadOptions\)
Start working with the Aspose.Imaging.FileFormats.Cdr.CdrImage class effortlessly by
initializing a new instance with a stream and loadOptions parameters.
Ideal for developers seeking a convenient way to load CDR images from
various data sources while customizing the loading process as needed.
```csharp
public CdrImage(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
The stream.
loadOptions
LoadOptions
The load options.
Exceptions
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 present in their images, ensuring accurate processing and manipulation.
public override int BitsPerPixel { get; }
Property Value
CdrDocument
Effortlessly retrieve or update the CDR document using this intuitive property. Ideal for developers seeking to access or modify the CDR document, ensuring flexibility and efficiency in their applications.
public CdrDocument CdrDocument { get; }
Property Value
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.
[Obsolete("Please use Pages[n]")]
public override Image DefaultPage { get; }
Property Value
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 FileFormat { get; }
Property Value
Height
Gets the image height.
public override int Height { get; }
Property Value
IsCached
Effortlessly 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.
public override bool IsCached { get; }
Property Value
PageCount
Effortlessly retrieve or update 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.
public override int PageCount { get; }
Property Value
Pages
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.
public override Image[] Pages { get; }
Property Value
Image[]
Examples
The following example shows how to cache all pages of a CDR image.```csharp [C#]
string dir = "c:\\temp\\";
// Load an image from a CDR file.
using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = (Aspose.Imaging.FileFormats.Cdr.CdrImage)Aspose.Imaging.Image.Load(dir + "sample.cdr"))
{
// 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.
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.```csharp
[C#]
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
Methods
CacheData()
Effortlessly cache the data to prevent additional loading from the underlying source with this user-friendly method. Ideal for developers seeking to optimize performance by preloading data, ensuring faster access and smoother operation in their applications. Aspose.Imaging.DataStreamSupporter.DataStreamContainer.
public override void CacheData()
Examples
The following example shows how to cache all pages of a CDR image.```csharp [C#]
string dir = "c:\\temp\\";
// Load an image from a CDR file.
using (Aspose.Imaging.FileFormats.Cdr.CdrImage image = (Aspose.Imaging.FileFormats.Cdr.CdrImage)Aspose.Imaging.Image.Load(dir + "sample.cdr"))
{
// 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.
foreach (Aspose.Imaging.FileFormats.Cdr.CdrImagePage page in image.Pages)
{
page.CacheData();
}
}
### <a id="Aspose_Imaging_FileFormats_Cdr_CdrImage_GetDefaultOptions_System_Object___"></a> GetDefaultOptions\(object\[\]\)
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.
```csharp
public override ImageOptionsBase GetDefaultOptions(object[] args)
Parameters
args
object[]
The arguments.
Returns
Default options
ReleaseManagedResources()
Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.
protected override void ReleaseManagedResources()
SaveData(Stream)
Saves the data.
protected override void SaveData(Stream stream)
Parameters
stream
Stream
The stream to save data to.
Exceptions
SetPalette(IColorPalette, bool)
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.
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 color
indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no
corresponding palette entries.