Class WmfSelectObject

Class WmfSelectObject

Namespace: Aspose.Imaging.FileFormats.Wmf.Objects
Assembly: Aspose.Imaging.dll (26.3.0)

The select object.

public class WmfSelectObject : WmfObject

Inheritance

object MetaObject WmfObject WmfSelectObject

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

WmfSelectObject(WmfGraphicObject)

Initializes a new instance of the Aspose.Imaging.FileFormats.Wmf.Objects.WmfSelectObject class.

public WmfSelectObject(WmfGraphicObject wmfObject)

Parameters

wmfObject WmfGraphicObject

The WMF object.

WmfSelectObject()

Initializes a new instance of the Aspose.Imaging.FileFormats.Wmf.Objects.WmfSelectObject class.

public WmfSelectObject()

Examples

The following example shows how set the background color for WMF. Actually it draws a rectangle of the background color before drawing all other objects.

string dir = "c:\\aspose.imaging\\issues\\net\\3280\\";
string inputFilePath = dir + "image2.wmf";
string outputFilePath = dir + "ChangeBackground_" + "image2.wmf";

using (Aspose.Imaging.FileFormats.Emf.MetaImage image = (Aspose.Imaging.FileFormats.Emf.MetaImage)Aspose.Imaging.Image.Load(inputFilePath))
{
    AddBackgroundRectangleWmf((Aspose.Imaging.FileFormats.Wmf.WmfImage)image, Aspose.Imaging.Color.Blue);
    image.Save(outputFilePath);
}

/// <summary>
/// Helper method to change WMF background. 
/// </summary>
public static void AddBackgroundRectangleWmf(Aspose.Imaging.FileFormats.Wmf.WmfImage image, Aspose.Imaging.Color color)
{
    image.CacheData();
    if (image.Records.Count < 1)
    {
        return;
    }

    //Set Rectangle
    Aspose.Imaging.FileFormats.Wmf.Objects.WmfRectangle rectangle = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfRectangle();
    rectangle.Rectangle = image.FrameBounds;

    //Set Brush
    Aspose.Imaging.FileFormats.Wmf.Objects.WmfCreateBrushInDirect brush = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfCreateBrushInDirect();
    brush.LogBrush = new Aspose.Imaging.FileFormats.Emf.Emf.Objects.EmfLogBrushEx();
    brush.LogBrush.Argb32ColorRef = color.ToArgb();

    //Select brush
    Aspose.Imaging.FileFormats.Wmf.Objects.WmfSelectObject selectObject = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfSelectObject(brush);

    //Remove brush
    Aspose.Imaging.FileFormats.Wmf.Objects.WmfDeleteObject deleteObject = new Aspose.Imaging.FileFormats.Wmf.Objects.WmfDeleteObject(brush);

    //Add records
    image.Records.Insert(0, brush);
    image.Records.Insert(1, selectObject);
    image.Records.Insert(2, rectangle);
    image.Records.Insert(3, deleteObject);
}

Properties

ObjectIndex

Gets or sets the index of the object.

public int ObjectIndex { get; set; }

Property Value

int

 English