Class EmfCreateBrushIndirect

Class EmfCreateBrushIndirect

Namespace: Aspose.Imaging.FileFormats.Emf.Emf.Records
Assembly: Aspose.Imaging.dll (25.4.0)

The EMR_CREATEBRUSHINDIRECT record defines a logical brush for graphics operations.

public sealed class EmfCreateBrushIndirect : EmfObjectCreationRecordType

Inheritance

objectMetaObjectEmfRecordEmfObjectCreationRecordTypeEmfCreateBrushIndirect

Inherited Members

EmfRecord.Type, EmfRecord.Size, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

EmfCreateBrushIndirect(EmfRecord)

Initializes a new instance of the Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfCreateBrushIndirect class.

public EmfCreateBrushIndirect(EmfRecord source)

Parameters

source EmfRecord

The source.

EmfCreateBrushIndirect()

Initializes a new instance of the Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfCreateBrushIndirect class.

public EmfCreateBrushIndirect()

Examples

The following example shows how set the background color for EMF. It actually puts a rectangle of the background color before drawing all other objects.

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

                                                                                                                                                                   using (Aspose.Imaging.FileFormats.Emf.MetaImage image = (Aspose.Imaging.FileFormats.Emf.MetaImage)Aspose.Imaging.Image.Load(inputFilePath))
                                                                                                                                                                   {
                                                                                                                                                                       AddBackgroundRectangleEmf((Aspose.Imaging.FileFormats.Emf.EmfImage)image, Aspose.Imaging.Color.Blue);

                                                                                                                                                                       image.Save(outputFilePath);
                                                                                                                                                                   }

                                                                                                                                                                   /// <summary>
                                                                                                                                                                   /// Helper method to change EMF background.
                                                                                                                                                                   /// </summary>
                                                                                                                                                                   public static void AddBackgroundRectangleEmf(Aspose.Imaging.FileFormats.Emf.EmfImage image, Aspose.Imaging.Color color)
                                                                                                                                                                   {
                                                                                                                                                                       image.CacheData();
                                                                                                                                                                       if (image.Records.Count &lt; 1)
                                                                                                                                                                       {
                                                                                                                                                                           return;
                                                                                                                                                                       }

                                                                                                                                                                       //Set Rectangle
                                                                                                                                                                       Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfRectangle rectangle = new Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfRectangle();
                                                                                                                                                                       rectangle.Box = image.Header.EmfHeader.Bounds;

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

                                                                                                                                                                       // Object indexes start at 1; zero is reserved for references to the metafile itself, see
                                                                                                                                                                       // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-emf/e4fa4e63-9096-4cdc-b776-85e2a1e4e1f4
                                                                                                                                                                       brush.IhBrush = 1;

                                                                                                                                                                       //Select brush
                                                                                                                                                                       Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfSelectObject selectObject = new Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfSelectObject();
                                                                                                                                                                       selectObject.ObjectHandle = 1;

                                                                                                                                                                       //Remove brush
                                                                                                                                                                       Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfDeleteObject deleteObject = new Aspose.Imaging.FileFormats.Emf.Emf.Records.EmfDeleteObject();
                                                                                                                                                                       deleteObject.ObjectHandle = 1;

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

Properties

IhBrush

Gets or sets A 32-bit unsigned integer that specifies the index of the logical brush object in the EMF Object Table (section 3.1.1.1). This index MUST be saved so that this object can be reused or modified.

public int IhBrush { get; set; }

Property Value

int

LogBrush

Gets or sets A LogBrushEx object (section 2.2.12) that specifies the style, color, and pattern of the logical brush. The BrushStyle field in this object MUST be BS_SOLID, BS_HATCHED, or BS_NULL.

public EmfLogBrushEx LogBrush { get; set; }

Property Value

EmfLogBrushEx