Table of Contents

Class DwfImage

Namespace
Aspose.CAD.FileFormats.Dwf
Assembly
Aspose.CAD.dll

DWF image class. Provides reading of DWF/DWFX format files, their processing and their export to other formats.

[ComVisible(false)]
public sealed class DwfImage : Image, IDisposable, IObjectWithBounds
Inheritance
DwfImage
Implements
Inherited Members

Examples

Reads an image file in DWG format, changes its contents and saves the image in PNG format.

string fileName = "exampleFile";
string file = string.Format("{0}.dwf", fileName);
string outFile = string.Format("{0}.png", fileName);
using (FileStream inStream = new FileStream(file, FileMode.Open))
using (DwfImage image = (DwfImage) Image.Load(inStream))
using (FileStream stream = new FileStream(outFile, FileMode.Create))
{
    DwfWhipDrawable[] entities = image.Pages[0].Entities;
    foreach(DwfWhipDrawable drawable in entities)
    {
        if(drawable is DwfWhipPolyline)
        {
            ((DwfWhipPolyline) drawable).Points[0].X = -50;
            ((DwfWhipPolyline) drawable).Points[0].Y = -50;
            break;
        }
    }  

    image.UpdateSize();

    foreach (DwfWhipDrawable drawable in entities)
    {
        if (drawable is DwfWhipText)
        {
            ((DwfWhipText)drawable).Font.Name.Value.AsciiString = "Arial";
        }
    }

    ImageOptionsBase options = new PngOptions();
    options.VectorRasterizationOptions = new CadRasterizationOptions
                                             {
                                                 PageWidth = (float)image.Pages[0].PaperWidth,
                                                 PageHeight = (float)image.Pages[0].PaperHeight,
                                                 DrawType = CadDrawTypeMode.UseObjectColor,
                                             };

    image.Save(stream, options);
}

Properties

Depth

Gets the image depth.

Height

Gets the image height. Defines the Y-axis distance between the bottommost point of all graphical objects in the image and their topmost point. The distance is measured in units corresponding to the value of the property UnitType

IsCached

Gets a value indicating whether object's data is cached currently and no data reading is required. Depending on the loading options only the necessary part of the data can be loaded into the cache from the image data. In this case, we can use this property to determine that only part of the image data is loaded into the cache.

Layers

Gets DWF pages layers. Returns the enumerable collection of DWF layers. The DWF data can be assigned to a specific DWF layer, which is a grouping drawing objects.

Pages

Gets the DWF pages. Returns an array of all DWF pages that are contained in the DWF image. Each DWF page defines all its available graphical parameters and all the objects that are drawn on it.

UnitType

Gets current unit type.

Width

Gets the image width. Defines the X-axis distance between the leftmost point of all graphic objects in the image and their rightmost point. The distance is measured in units corresponding to the value of the property UnitType

Methods

AddElement(int, DwfWhipDrawable)

Adds graphic element to specified page. Provides an opportunity to add a new graphic element to the existing ones in the image. To add it, you need to create a new graphic element and specify the index of the page in Pages array to which the element should be added.

CacheData()

Caches the data and ensures no additional data loading will be performed from the underlying DataStreamContainer. Depending on the loading options only the necessary part of the data can be loaded into the cache from the image data. In this case, we can use this method to load all image data into the cache.

GetElementCount(int)

Gets count of graphic elements from specified page. Provides the ability to determine the number of graphic elements on a specific image page. To get this value, you need to specify the page index in the array Pages, the number of elements of which you want to get.

GetStrings()

Gets all string values from image. Provides an opportunity to get the values of all text graphic elements present in the image in the form of an array of strings.

ReleaseManagedResources()

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

RemoveElement(int, int)

Removes graphic element from specified page. Provides the ability to remove a graphic element from the image. To remove it, you need to specify the page index in Pages array from which the element should be removed and the index of the element in Entities array.

SaveData(Stream)

Saves data

UpdateSize()

Updates the image size. Provides forced calculation of image size parameters. This calculation must be performed before using the image size parameters after changing the graphic content of the image that affects the image size parameters.