Class WmfRecorderGraphics2D

Class WmfRecorderGraphics2D

Namespace: Aspose.Imaging.FileFormats.Wmf.Graphics
Assembly: Aspose.Imaging.dll (25.7.0)

The Wmf recorder.

public sealed class WmfRecorderGraphics2D : MetafileRecorderGraphics2D
   {
   }

Inheritance

object MetafileRecorderGraphics2D WmfRecorderGraphics2D

Inherited Members

MetafileRecorderGraphics2D.Clear() , MetafileRecorderGraphics2D.DrawArc(Pen, Rectangle, float, float) , MetafileRecorderGraphics2D.DrawCubicBezier(Pen, Point, Point, Point, Point) , MetafileRecorderGraphics2D.DrawPolyCubicBezier(Pen, Point[]) , MetafileRecorderGraphics2D.DrawEllipse(Pen, Rectangle) , MetafileRecorderGraphics2D.FillEllipse(Brush, Rectangle) , MetafileRecorderGraphics2D.DrawImage(RasterImage, Point) , MetafileRecorderGraphics2D.DrawImage(RasterImage, Rectangle, Rectangle, GraphicsUnit) , MetafileRecorderGraphics2D.DrawImage(byte[], Rectangle, GraphicsUnit) , MetafileRecorderGraphics2D.DrawImage(Stream, Rectangle, GraphicsUnit) , MetafileRecorderGraphics2D.DrawLine(Pen, int, int, int, int) , MetafileRecorderGraphics2D.DrawLine(Pen, Point, Point) , MetafileRecorderGraphics2D.DrawPolyline(Pen, Point[]) , MetafileRecorderGraphics2D.DrawPath(Pen, GraphicsPath) , MetafileRecorderGraphics2D.FillPath(Pen, Brush, GraphicsPath) , MetafileRecorderGraphics2D.DrawPie(Pen, Rectangle, float, float) , MetafileRecorderGraphics2D.FillPie(Brush, Rectangle, float, float) , MetafileRecorderGraphics2D.DrawPolygon(Pen, Point[]) , MetafileRecorderGraphics2D.FillPolygon(Brush, Point[]) , MetafileRecorderGraphics2D.FillPolygon(Brush, Point[], FillMode) , MetafileRecorderGraphics2D.DrawRectangle(Pen, int, int, int, int) , MetafileRecorderGraphics2D.DrawRectangle(Pen, Rectangle) , MetafileRecorderGraphics2D.FillRectangle(Brush, Rectangle) , MetafileRecorderGraphics2D.DrawString(string, Font, Color, int, int) , MetafileRecorderGraphics2D.DrawString(string, Font, Color, int, int, float) , MetafileRecorderGraphics2D.ExcludeClip(Rectangle) , MetafileRecorderGraphics2D.ExcludeClip(Region) , MetafileRecorderGraphics2D.IntersectClip(RectangleF) , MetafileRecorderGraphics2D.IntersectClip(Region) , MetafileRecorderGraphics2D.ResetClip() , MetafileRecorderGraphics2D.MultiplyTransform(Matrix) , MetafileRecorderGraphics2D.MultiplyTransform(Matrix, MatrixOrder) , MetafileRecorderGraphics2D.TranslateTransform(float, float) , MetafileRecorderGraphics2D.TranslateTransform(float, float, MatrixOrder) , MetafileRecorderGraphics2D.RotateTransform(float) , MetafileRecorderGraphics2D.RotateTransform(float, PointF, MatrixOrder) , MetafileRecorderGraphics2D.ScaleTransform(float, float) , MetafileRecorderGraphics2D.ScaleTransform(float, float, MatrixOrder) , MetafileRecorderGraphics2D.GetTransform() , MetafileRecorderGraphics2D.SetTransform(Matrix) , MetafileRecorderGraphics2D.Clip , MetafileRecorderGraphics2D.ClipBounds , MetafileRecorderGraphics2D.BackgroundColor , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

WmfRecorderGraphics2D(Rectangle, int)

Initializes a new instance of the Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D class.

public WmfRecorderGraphics2D(Rectangle frame, int inch)
   {
   }

Parameters

frame Rectangle

Destination rectangle, measured in twips, for displaying the metafile.

inch int

The number of pixel per inch.

Examples

This example shows how to create a WMF image and draw some geometric shapes using WmfRecorderGraphics2D.

string dir = "c:\\temp\\";
   int imageWidth = 600;
   int imageHeight = 400;
   int dpi = 96;
   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);
   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);
   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);
   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));
   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);
   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);
   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);
   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
       new Aspose.Imaging.Point(0, 0),
       new Aspose.Imaging.Point(200, 133),
       new Aspose.Imaging.Point(400, 166),
       new Aspose.Imaging.Point(600, 400));
   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
   {
       graphics.DrawImage(imageToDraw,
           new Aspose.Imaging.Rectangle(400, 200, 100, 50),
           new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight),
           Aspose.Imaging.GraphicsUnit.Pixel);
   }
   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);
   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
   figureToFill.IsClosed = true;
   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
   pathToFill.AddFigure(figureToFill);
   figureToFill.AddShapes(new Shape[]
   {
       new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
       new Aspose.Imaging.Shapes.BezierShape(
           new Aspose.Imaging.PointF[]
           {
               new Aspose.Imaging.PointF(300, 200),
               new Aspose.Imaging.PointF(400, 200),
               new Aspose.Imaging.PointF(500, 100),
               new Aspose.Imaging.PointF(600, 200)
           }),
       new Aspose.Imaging.Shapes.PolygonShape(
           new Aspose.Imaging.PointF[]
           {
               new Aspose.Imaging.PointF(300, 100)
           }),
       new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200))
   });
   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);
   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
   pathToDraw.AddFigure(figureToDraw);
   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
   {
       new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360)
   });
   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);
   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
   saveOptions.VectorRasterizationOptions = rasterizationOptions;
   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
   {
       wmfImage.Save(dir + "test.output.wmf");
   }

Properties

BackgroundMode

Gets or sets the background mode.

public WmfMixMode BackgroundMode
    {
        get;
        set;
    }

Property Value

WmfMixMode

Methods

EndRecording()

Ends the recording.

public WmfImage EndRecording()
    {
    }
Assuming that this is the entire method body, I cannot format it further as there's no additional content to be indented or spaced. If more code follows within this method, I will adjust the indentation accordingly.

Returns

WmfImage

The result image.

Examples

This example shows how to create a WMF image and draw some geometric shapes using WmfRecorderGraphics2D.

string dir = "c:\\temp\\";
   int imageWidth = 600;
   int imageHeight = 400;
   int dpi = 96;
   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);
   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);
   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);
   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));
   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, imageWidth, imageHeight);
   graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, imageHeight, imageWidth, 0);
   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);
   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);
   graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
       new Aspose.Imaging.Point(0, 0),
       new Aspose.Imaging.Point(200, 133),
       new Aspose.Imaging.Point(400, 166),
       new Aspose.Imaging.Point(600, 400));
   using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
   {
       graphics.DrawImage(imageToDraw,
           new Aspose.Imaging.Rectangle(400, 200, 100, 50),
           new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight),
           Aspose.Imaging.GraphicsUnit.Pixel);
   }
   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);
   Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
   figureToFill.IsClosed = true;
   Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
   pathToFill.AddFigure(figureToFill);
   figureToFill.AddShapes(new Shape[]
       {
           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
           new Aspose.Imaging.Shapes.BezierShape(
               new Aspose.Imaging.PointF[]
               {
                   new Aspose.Imaging.PointF(300, 200),
                   new Aspose.Imaging.PointF(400, 200),
                   new Aspose.Imaging.PointF(500, 100),
                   new Aspose.Imaging.PointF(600, 200),
               }),
           new Aspose.Imaging.Shapes.PolygonShape(
               new Aspose.Imaging.PointF[]
               {
                   new Aspose.Imaging.PointF(300, 100),
               }),
           new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
       });
   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);
   Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
   Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
   pathToDraw.AddFigure(figureToDraw);
   figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
       {
           new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
       });
   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);
   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
   saveOptions.VectorRasterizationOptions = rasterizationOptions;
   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
   {
       wmfImage.Save(dir + "test.output.wmf");
   }

FromWmfImage(WmfImage)

Gets an instance of the Wmf recorder for the existing Wmf image.

public static Aspose.Words.CheckBox.WmfRecorderGraphics2D FromWmfImage(Aspose.Words.CheckBox.WmfImage wmfImage)
   {
   }

Parameters

wmfImage WmfImage

The Wmf image to get a recoreder for.

Returns

WmfRecorderGraphics2D

An instance of the Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D class.

 English