Class OdgImage

OdgImage class

Manipulate OpenDocument Graphic (ODG) vector image file format with our API, widely used by OpenOffice and LibreOffice Draw applications for storing drawing elements in a vector format. Seamlessly parse documents, access pages, resize and rotate images, ensuring efficient processing and customization of ODG files to meet your specific requirements.

public class OdgImage : OdImage

Constructors

NameDescription
OdgImage(StreamContainer)Crafted for seamless integration into software solutions, the OdgImage constructor initializes a new instance by leveraging a stream container. This method ensures efficient handling of ODG image data within software environments, optimizing resource utilization and facilitating streamlined image processing workflows.
OdgImage(StreamContainer, LoadOptions)Start a new creation of the OdgImage class object with the initiation of a fresh instance. Harness the potential of a stream container coupled with load options parameters, maintain a versatile constructor to seamlessly load images. This constructor empowers efficient image handling, offering customizable loading configurations for enhanced adaptability and performance across diverse scenarios.

Properties

NameDescription
AutoAdjustPalette { get; set; }Gets or sets a value indicating whether automatic adjust palette.
virtual BackgroundColor { get; set; }Gets or sets a value for the background color.
override BitsPerPixel { get; }Retrieves the count of bits per pixel for the image. This property provides insight into the level of detail and color depth represented in the image, aiding in various image processing tasks and optimizations.
Bounds { get; }Gets the image bounds.
BufferSizeHint { get; set; }Gets or sets the buffer size hint which is defined max allowed size for all internal buffers.
Container { get; }Gets the Image container.
DataStreamContainer { get; }Gets the object’s data stream.
Disposed { get; }Gets a value indicating whether this instance is disposed.
override FileFormat { get; }Gets a value of file format
virtual HasBackgroundColor { get; set; }Gets or sets a value indicating whether image has background color.
override Height { get; }Returns the height of the image, denoting the vertical dimension in pixels. This property is crucial for understanding the image’s overall size and proportions, facilitating accurate display and processing of image content.
virtual HeightF { get; }Gets the object height, in inches.
InterruptMonitor { get; set; }Gets or sets the interrupt monitor.
override IsCached { get; }Obtains a boolean value indicating whether the data of the object is currently cached, thus eliminating the need for data reading. This property serves as an optimization indicator, enhancing performance by minimizing redundant data access operation.
Metadata { get; }Retrieves metadata specific to OpenDocument files. This property allows access to essential information embedded within OD files, facilitating various operations such as extraction, modification, or analysis of metadata.
override PageCount { get; }Retrieves the total count of pages within the image. This property is essential for applications managing multi-page images, enabling them to accurately determine the number of pages available for processing or display.
virtual PageExportingAction { get; set; }Gets or sets the page exporting action. Please note that setting this method will automatically release page resources after it is executed. It will be executed just before each page is saved.
override Pages { get; }Retrieving the collection of pages, this property empowers to access the entirety of pages associated with an image. By accessing this property, developers can iterate through individual pages, retrieve specific pages based on their index, or perform batch operations on the entire collection.
Palette { get; set; }Gets or sets the color palette. The color palette is not used when pixels are represented directly.
Records { get; }Retrieves the OpenDocument records stored within the image. This property grants access to specific structured data elements embedded within OpenDocument files, facilitating retrieval or manipulation of relevant information for further processing or analysis.
Size { get; }Gets the image size.
SizeF { get; }Gets the object size, in inches.
virtual UsePalette { get; }Gets a value indicating whether the image palette is used.
override Width { get; }Retrieves the width of the image, indicating the horizontal dimension in pixels. This property provides essential information about the image’s size, enabling precise rendering, manipulation, and analysis of image data.
virtual WidthF { get; }Gets the object width, in inches.

Methods

NameDescription
override CacheData()Caches the data and ensures no additional data loading will be performed from the underlying DataStreamContainer.
CanSave(ImageOptionsBase)Determines whether image can be saved to the specified file format represented by the passed save options.
Dispose()Disposes the current instance.
override GetDefaultOptions(object[])This property provides access to the default options associated with an image. By retrieving these options, developers can quickly ascertain the default settings applied to the image, facilitating the creation of new instances or the modification of existing ones based on these presets.
override GetEmbeddedImages()Gets the embedded images.
virtual GetOriginalOptions()Gets the options based on the original file settings. This can be helpful to keep bit-depth and other parameters of the original image unchanged. For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the Save method, the output PNG image with 8-bit per pixel will be produced. To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them to the Save method as the second parameter.
override GetSerializedStream(ImageOptionsBase, Rectangle, out int)Converts to aps.
RemoveBackground()Removes the background.
RemoveBackground(RemoveBackgroundSettings)Removes the background.
virtual RemoveMetadata()Removes metadata.
Resize(int, int)Resizes the image. The default NearestNeighbourResample is used.
override Resize(int, int, ImageResizeSettings)This method helps developers to resize images programmatically. By invoking this function, you can dynamically adjust the dimensions of images, catering to specific requirements or constraints within their applications.
override Resize(int, int, ResizeType)This method facilitates image resizing with precise control over width, height, and resize type parameters. You can specify the desired dimensions and choose from different resizing algorithms or types to achieve optimal results based on application’s requirements.
ResizeHeightProportionally(int)Resizes the height proportionally. The default NearestNeighbourResample is used.
virtual ResizeHeightProportionally(int, ImageResizeSettings)Resizes the height proportionally.
virtual ResizeHeightProportionally(int, ResizeType)Resizes the height proportionally.
ResizeWidthProportionally(int)Resizes the width proportionally. The default NearestNeighbourResample is used.
virtual ResizeWidthProportionally(int, ImageResizeSettings)Resizes the width proportionally.
virtual ResizeWidthProportionally(int, ResizeType)Resizes the width proportionally.
override RotateFlip(RotateFlipType)This versatile method apply various transformations to images, including rotation and flipping, to achieve desired orientations and visual effects. With intuitive parameters, you can specify the degree of rotation and the type of flipping (horizontal, vertical, or both) to precisely manipulate the image as needed.
Save()Saves the image data to the underlying stream.
Save(Stream)Saves the object’s data to the specified stream.
override Save(string)Saves the image to the specified file location.
Save(Stream, ImageOptionsBase)Saves the image’s data to the specified stream in the specified file format according to save options.
virtual Save(string, bool)Saves the object’s data to the specified file location.
virtual Save(string, ImageOptionsBase)Saves the object’s data to the specified file location in the specified file format according to save options.
virtual Save(Stream, ImageOptionsBase, Rectangle)Saves the image’s data to the specified stream in the specified file format according to save options.
virtual Save(string, ImageOptionsBase, Rectangle)Saves the object’s data to the specified file location in the specified file format according to save options.
override SetPalette(IColorPalette, bool)Sets the image palette.

Examples

This example loads a multi-page ODG image.

[C#]

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

// Using Aspose.Imaging.Image.Load is a unified way to load image.
using (Aspose.Imaging.FileFormats.OpenDocument.OdImage image = (Aspose.Imaging.FileFormats.OpenDocument.OdImage)Aspose.Imaging.Image.Load(dir + "sample.odg"))
{
    // Cast to OdgImage
    Aspose.Imaging.FileFormats.OpenDocument.OdgImage odgImage = (Aspose.Imaging.FileFormats.OpenDocument.OdgImage)image;

    // Get all pages
    Aspose.Imaging.Image[] pages = odgImage.Pages;

    // Do some image processing
}

The following example shows how to export a FODG (Flat XML ODF Template) image to PDF format.

[C#]

string dir = "c:\\aspose.imaging\\issues\\net\\3635";

string inputFileName = System.IO.Path.Combine(dir, "VariousObjectsMultiPage.fodg");
string outputFileName = inputFileName + ".pdf";

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(inputFileName))
{
    Aspose.Imaging.ImageOptions.OdgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.OdgRasterizationOptions();
    rasterizationOptions.BackgroundColor = Aspose.Imaging.Color.White;
    rasterizationOptions.PageSize = image.Size;

    Aspose.Imaging.ImageOptions.PdfOptions saveOptions = new Aspose.Imaging.ImageOptions.PdfOptions();
    saveOptions.VectorRasterizationOptions = rasterizationOptions;

    image.Save(outputFileName, saveOptions);
}

See Also