Class MetafileRecorderGraphics2D

Class MetafileRecorderGraphics2D

Названий на: Aspose.Imaging.FileFormats.Emf.Graphics Асамблея: Aspose.Imaging.dll (25.4.0)

Метафілі записи графіки

public abstract class MetafileRecorderGraphics2D

Inheritance

object MetafileRecorderGraphics2D

Derived

EmfRecorderGraphics2D , WmfRecorderGraphics2D

Нападні члени

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

Properties

BackgroundColor

Приймати або встановити колір фону.

public Color BackgroundColor { get; set; }

вартість нерухомості

Color

BackgroundMode

Приймати або встановити режим фону.

protected int BackgroundMode { get; set; }

вартість нерухомості

int

Clip

Знайти або встановити Регіон, який обмежує рисований регіон цієї Графіки

public Region Clip { get; set; }

вартість нерухомості

Region

ClipBounds

Використовуйте лінії кліпу.

public RectangleF ClipBounds { get; }

вартість нерухомості

RectangleF

Methods

Clear()

Визначити стан графічного об’єкта

public void Clear()

DrawArc(Пінгвіни, Пінгвіни, Пінгвіни)

Витягує арку, що являє собою частину еліпсу, визначену прямокутною структурою.

public void DrawArc(Pen pen, Rectangle rect, float startAngle, float arcAngle)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

rect Rectangle

Країни еліпсу.

startAngle float

Уголь у ступенях вимірюється годинником від х-акси до початкової точки арку.

arcAngle float

Уголь у ступенях вимірюється годинником від стартуАнджелевий параметр до кінця точки арку.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

DrawCubicBezier(Пін, точка, точка, точка)

Використовуйте кубічний безпір.

public void DrawCubicBezier(Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

pt1 Point

Початкова точка криви.

pt2 Point

Перша контрольна точка для криви.

pt3 Point

Друга контрольна точка для криви.

pt4 Point

Кінцева точка криви.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

DrawEllipse(Пін, прямокутний)

Використовуйте еліпс.

public void DrawEllipse(Pen pen, Rectangle rect)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

rect Rectangle

Країни еліпсу.

DrawImage(Створення Point, Point)

Знайдіть зазначене зображення, використовуючи його оригінальний фізичний розмір, на зазначеному місці.

public void DrawImage(RasterImage image, Point location)

Parameters

image RasterImage

Зображення для зображення.

location Point

Місце розташування верхнього лівого кута зображення.

DrawImage(Створення RasterImage, Rectangle, GraphicsUnit)

Натисніть зазначену частину зазначеного зображення на зазначеному місці та з зазначений розмір.

public void DrawImage(RasterImage image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)

Parameters

image RasterImage

Зображення для зображення.

destRect Rectangle

Структура прямокутника, яка визначає місце розташування і розмір витягнутого зображення.

srcRect Rectangle

Структура прямокутника, яка визначає частину зображення об’єкта, який потрібно малювати.

srcUnit GraphicsUnit

Об’єкти міри, що використовуються параметром srcRect.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

Exceptions

ArgumentOutOfRangeException

srcUnit;Підтримка тільки пікселів

DrawImage(Батьківщина[ ], Ректанглі, Графіки)

Знайдіть зображення.

public void DrawImage(byte[] imageBytes, Rectangle destRect, GraphicsUnit srcUnit)

Parameters

imageBytes byte [ ]

Зображення має байт.

destRect Rectangle

Це прямий шлях.

srcUnit GraphicsUnit

Джерельна одиниця .

DrawImage(Потік, ректонгл, графіки)

Знайдіть зображення.

public void DrawImage(Stream stream, Rectangle destRect, GraphicsUnit srcUnit)

Parameters

stream Stream

і потоку .

destRect Rectangle

Це прямий шлях.

srcUnit GraphicsUnit

Джерельна одиниця .

DrawLine(Пін, int, int, int, int)

Натисніть лінію.

public void DrawLine(Pen pen, int x1, int y1, int x2, int y2)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

x1 int

Координат X першого пункту.

y1 int

Координація першого пункту.

x2 int

Координат X з другої точки.

y2 int

Координати другого пункту.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

DrawLine(Пін, точка і точка)

Натисніть лінію.

public void DrawLine(Pen pen, Point pt1, Point pt2)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

pt1 Point

Перший пункт .

pt2 Point

Другий пункт .

DrawPath(Пін, GraphicsPath)

Знайдіть шлях.

public void DrawPath(Pen pen, GraphicsPath path)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

path GraphicsPath

Дорога до зйомок.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

DrawPie(Пінгвіни, Пінгвіни, Пінгвіни)

Знайдіть печінку.

public void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

rect Rectangle

Країни еліпсу.

startAngle float

Уголь у ступенях вимірюється годинником від х-акси до початкової точки арку.

sweepAngle float

Уголь у ступенях вимірюється годинником від стартуАнджелевий параметр до кінця точки арку.

DrawPolyCubicBezier(Пін, точка[])

Використовуйте полі кубічний безьєр.

public void DrawPolyCubicBezier(Pen pen, Point[] points)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

points Point [ ]

І ось точки.

Exceptions

ArgumentOutOfRangeException

Кількість пунктів в ряді повинна бути кількома 3 плюс 1, наприклад, 4, 7 або 10.

DrawPolygon(Пін, точка[])

Використовуйте полігон.

public void DrawPolygon(Pen pen, Point[] points)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

points Point [ ]

І ось точки.

DrawPolyline(Пін, точка[])

Використовуйте полілін.

public void DrawPolyline(Pen pen, Point[] points)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

points Point [ ]

І ось точки.

DrawRectangle(Пін, int, int, int, int)

Витягніть прямокутник.

public void DrawRectangle(Pen pen, int x, int y, int width, int height)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

x int

X-координат верхньо-лівого кута прямокутника для витягування.

y int

Y-координат верхньо-лівого кута прямокутника для витягування.

width int

Ширина прямокутника для витягування.

height int

Висота прямокутника для витягування.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

DrawRectangle(Пін, прямокутний)

Витягніть прямокутник.

public void DrawRectangle(Pen pen, Rectangle rectangle)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

rectangle Rectangle

Прямий колір для витягування.

DrawString(колір, шрифт, фар, int)

Використовуйте стрічку.

public void DrawString(string @string, Font font, Color color, int x, int y)

Parameters

string string

Це стрічка.

font Font

Шрифт, який визначає текстовий формат стрічки.

color Color

Колір тексту .

x int

X-координат верхньо-лівого кута витягнутого тексту.

y int

Y-координат верхньо-лівого кута витягнутого тексту.

Examples

Цей приклад показує, як завантажити зображення EMF з файлу і витягнути над ним текстовий ряд.

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

                                                                                                 using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = (Aspose.Imaging.FileFormats.Emf.EmfImage)Aspose.Imaging.Image.Load(dir + "test.emf"))
                                                                                                 {
                                                                                                     Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D.FromEmfImage(emfImage);

                                                                                                     // First, get the image size
                                                                                                     int width = emfImage.Width;
                                                                                                     int height = emfImage.Height;

                                                                                                     // Second, calculate a transformation to put a text string along the main diagonal of the image -
                                                                                                     // from the upper-left to the bootom-right corner.
                                                                                                     float emFontSize = 96f;
                                                                                                     float d = (float)System.Math.Sqrt(width * width + height * height);
                                                                                                     float scaleFactor = d / (emFontSize * 5f);

                                                                                                     float tan = ((float)height) / width;                
                                                                                                     double radians = System.Math.Atan(tan);
                                                                                                     double degrees = (180 * radians) / System.Math.PI;

                                                                                                     Aspose.Imaging.Matrix transform = new Aspose.Imaging.Matrix();
                                                                                                     transform.Rotate((float)degrees);
                                                                                                     transform.Scale(scaleFactor, scaleFactor);

                                                                                                     // Then, set the transform.
                                                                                                     graphics.SetTransform(transform);

                                                                                                     // Finally, put a watermark (text string of pink color) along the main diagonal.
                                                                                                     graphics.DrawString("WATERMARK", new Aspose.Imaging.Font("Courier New", emFontSize), Aspose.Imaging.Color.LightPink, 0, 0/*, (float)degrees*/);

                                                                                                     // Save the image with watermark to another EMF file.
                                                                                                     using (Aspose.Imaging.FileFormats.Emf.EmfImage scaledEmfImage = graphics.EndRecording())
                                                                                                     {
                                                                                                         scaledEmfImage.Save(dir + "test.scaled.emf");
                                                                                                     }
                                                                                                 }

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

DrawString(Стриг, Font, Color, Int, int, Float)

Використовуйте стрічку.

public void DrawString(string @string, Font font, Color color, int x, int y, float angle)

Parameters

string string

Це стрічка.

font Font

Шрифт, який визначає текстовий формат стрічки.

color Color

Колір тексту .

x int

X-координат верхньо-лівого кута витягнутого тексту.

y int

Y-координат верхньо-лівого кута витягнутого тексту.

angle float

Уголь у ступенях, між вихідним вектором і кс-осі пристрою.Вихідний вектор паралельний до базової лінії тексту.

ExcludeClip(Rectangle)

Оновлює кліп-регіон цієї Графіки, щоб виключити область, зазначену структурою прямокутника.

public void ExcludeClip(Rectangle rect)

Parameters

rect Rectangle

Структура прямокутного кута, яка визначає прямий кут для виключення з кліп-регіону.

ExcludeClip(Region)

Оновлює кліп-регіон цієї Графіки, щоб виключити область, зазначену Регіоном.

public void ExcludeClip(Region region)

Parameters

region Region

Регіон, який визначає регіон для виключення з кліп-регіону.

FillEllipse(Штукатурка, ректорантура)

Залишився еліпс.

public void FillEllipse(Brush brush, Rectangle rect)

Parameters

brush Brush

Штукатурка, яка визначає характеристики наповнення.

rect Rectangle

Країни еліпсу.

FillPath(Пін, Брюш, ГрафікиPath)

Завершився шлях.

public void FillPath(Pen pen, Brush brush, GraphicsPath path)

Parameters

pen Pen

Пен, який визначає колір, ширину і стиль зображення.

brush Brush

Штукатурка, яка визначає характеристики наповнення.

path GraphicsPath

Дорога до заповнення.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

FillPie(Штукатурка, прямий колір, плавання, плавання)

Залишився пейзаж.

public void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle)

Parameters

brush Brush

Штукатурка, яка визначає характеристики наповнення.

rect Rectangle

Країни еліпсу.

startAngle float

Уголь у ступенях вимірюється годинником від х-акси до початкової точки арку.

sweepAngle float

Уголь у ступенях вимірюється годинником від стартуАнджелевий параметр до кінця точки арку.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

FillPolygon(Брюш, точка[])

Використовуйте полігон.

public void FillPolygon(Brush brush, Point[] points)

Parameters

brush Brush

Штукатурка, яка визначає характеристики наповнення.

points Point [ ]

І ось точки.

FillPolygon(Брюш, точка[ ], Створення Fill)

Використовуйте полігон.

public void FillPolygon(Brush brush, Point[] points, FillMode fillMode)

Parameters

brush Brush

Штукатурка, яка визначає характеристики наповнення.

points Point [ ]

І ось точки.

fillMode FillMode

Завантажити модуль.

FillRectangle(Штукатурка, ректорантура)

Заповніть прямокутник.

public void FillRectangle(Brush brush, Rectangle rectangle)

Parameters

brush Brush

Штукатурка, яка визначає характеристики наповнення.

rectangle Rectangle

Залишився прямокутник для заповнення.

Examples

Цей приклад показує, як створити зображення WMF і малювати деякі геометричні форми за допомогою WmfRecorderGraphics2D.

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

                                                                                                                   int imageWidth = 600;
                                                                                                                   int imageHeight = 400;

                                                                                                                   // This is the default screen resolution.
                                                                                                                   int dpi = 96;

                                                                                                                   Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, imageWidth, imageHeight);

                                                                                                                   // Create a WMF image.
                                                                                                                   Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D graphics =
                                                                                                                       new Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D(frame, dpi);

                                                                                                                   // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                   graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, imageWidth, imageHeight);

                                                                                                                   // Fill a rectangle with the color of white-smoke.
                                                                                                                   graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                   // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                   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);

                                                                                                                   // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                   graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                   // Fill an arc
                                                                                                                   graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                   // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                   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));

                                                                                                                   // Draw a raster image of the specified size at the specified location.
                                                                                                                   // The image is scaled to fit the desired rectangle.
                                                                                                                   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);
                                                                                                                   }

                                                                                                                   // Draw a text string
                                                                                                                   graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                   // Create a path to fill
                                                                                                                   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)),
                                                                                                                       });

                                                                                                                   // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                   graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                   // Create a path to draw
                                                                                                                   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),
                                                                                                                       });

                                                                                                                   // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                   graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                   // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                   Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                   Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                   saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                   // Get the final WMF image which includes all drawing commands
                                                                                                                   using (Aspose.Imaging.FileFormats.Wmf.WmfImage wmfImage = graphics.EndRecording())
                                                                                                                   {
                                                                                                                       wmfImage.Save(dir + "test.output.wmf");
                                                                                                                   }

Цей приклад показує, як створити зображення EMF і малювати деякі геометричні форми на ньому за допомогою EmfRecorderGraphics2D.

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

                                                                                                                         // The image size in pixels
                                                                                                                         int deviceWidth = 600;
                                                                                                                         int deviceHeight = 400;

                                                                                                                         // The image size in millimiters
                                                                                                                         int deviceWidthMm = (int)(deviceWidth / 100f);
                                                                                                                         int deviceHeightMm = (int)(deviceHeight / 100f);

                                                                                                                         Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Create a EMF image.
                                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                                             new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
                                                                                                                                 frame,
                                                                                                                                 new Aspose.Imaging.Size(deviceWidth, deviceHeight),
                                                                                                                                 new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));

                                                                                                                         // Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
                                                                                                                         graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);

                                                                                                                         // Fill a rectangle with the color of white-smoke.
                                                                                                                         graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));

                                                                                                                         // Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
                                                                                                                         graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);

                                                                                                                         // Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
                                                                                                                         graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);

                                                                                                                         // Fill an arc
                                                                                                                         graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);

                                                                                                                         // Draw a cubic bezier using a 2-pixel-wide red pen.
                                                                                                                         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));

                                                                                                                         // Draw a raster image of the specified size at the specified location.
                                                                                                                         // The image is scaled to fit the desired rectangle.
                                                                                                                         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, deviceWidth, deviceHeight),
                                                                                                                                 Aspose.Imaging.GraphicsUnit.Pixel);
                                                                                                                         }

                                                                                                                         // Draw a text string
                                                                                                                         graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);

                                                                                                                         // Create a path to fill
                                                                                                                         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)),
                                                                                                                             });

                                                                                                                         // Fill the path using a yellow brush and a green pen to draw outline
                                                                                                                         graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);

                                                                                                                         // Create a path to draw
                                                                                                                         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),
                                                                                                                             });

                                                                                                                         // Draw the path using a 5-pixel-wide orange pen.
                                                                                                                         graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);

                                                                                                                         // In order to rasterize SVG we need to specify rasterization options.
                                                                                                                         Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
                                                                                                                         Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
                                                                                                                         saveOptions.VectorRasterizationOptions = rasterizationOptions;

                                                                                                                         // Get the final WMF image which includes all drawing commands
                                                                                                                         using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
                                                                                                                         {
                                                                                                                             emfImage.Save(dir + "test.output.emf");
                                                                                                                         }

GetTransform()

Він перетворює світ.

public Matrix GetTransform()

Returns

Matrix

Трансформація матриці.

IntersectClip(Ректанглі)

Оновлюється кліп-регіон цієї Графіки до перехрестя поточного кліпу та визначеної структури Ректангу.

public void IntersectClip(RectangleF rect)

Parameters

rect RectangleF

Структура прямокутника перетинається з поточним регіоном кліпу.

IntersectClip(Region)

Оновлюється кліп-регіон цієї Графіки до перехрестя поточного кліпу та зазначеного регіону.

public void IntersectClip(Region region)

Parameters

region Region

Співвідношення з нинішнім регіоном.

MultiplyTransform(Matrix)

Він умножує світову трансформацію цієї графіки і визначає матрицю.

public void MultiplyTransform(Matrix matrix)

Parameters

matrix Matrix

Матрика, яка умножує світову трансформацію.

MultiplyTransform(Матриця, MatrixOrder)

Умножує світову трансформацію цієї графіки і визначає матрицю в визначеному порядку.

public void MultiplyTransform(Matrix matrix, MatrixOrder order)

Parameters

matrix Matrix

Матрика, яка умножує світову трансформацію.

order MatrixOrder

Порядок розмноження.

ResetClip()

Відновлюйте кліп.

public void ResetClip()

RotateTransform(Флота)

Використовує визначену ротацію для трансформаційної матриці цієї Графіки.

public void RotateTransform(float angle)

Parameters

angle float

Уголь ротації в ступенях.

RotateTransform(Створення PointF, MatrixOrder)

Використовуйте визначену ротацію для трансформаційної матриці цієї Графіки в визначеному порядку.

public void RotateTransform(float angle, PointF center, MatrixOrder order)

Parameters

angle float

Уголь ротації в ступенях.

center PointF

Це ротаційний центр.

order MatrixOrder

Визначає, чи є обертання прикріпленим або перев’язаним до матричної трансформації.

ScaleTransform(Флотація, Флотація)

Використовує специфіковану операцію скалювання для трансформаційної матриці цієї Графіки, прив’язуючи її до трансформиальної матерії об’єкта.

public void ScaleTransform(float sx, float sy)

Parameters

sx float

Фактор масштабу в напрямку x.

sy float

Фактор масштабу в напрямку і.

ScaleTransform(плавання, плавання, MatrixOrder)

Використовує визначену операцію скалювання для трансформаційної матриці цієї Графіки в визначеному порядку.

public void ScaleTransform(float sx, float sy, MatrixOrder order)

Parameters

sx float

Фактор масштабу в напрямку x.

sy float

Фактор масштабу в напрямку і.

order MatrixOrder

Визначає, чи переповнена або прикріплена операція скалювання до матриці трансформації.

SetTransform(Matrix)

Складіть трансформацію.

public void SetTransform(Matrix transform)

Parameters

transform Matrix

Новий трансформатор матриці.

Examples

Цей приклад показує, як завантажити зображення EMF з файлу і витягнути над ним текстовий ряд.

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

                                                                                                 using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = (Aspose.Imaging.FileFormats.Emf.EmfImage)Aspose.Imaging.Image.Load(dir + "test.emf"))
                                                                                                 {
                                                                                                     Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
                                                                                                         Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D.FromEmfImage(emfImage);

                                                                                                     // First, get the image size
                                                                                                     int width = emfImage.Width;
                                                                                                     int height = emfImage.Height;

                                                                                                     // Second, calculate a transformation to put a text string along the main diagonal of the image -
                                                                                                     // from the upper-left to the bootom-right corner.
                                                                                                     float emFontSize = 96f;
                                                                                                     float d = (float)System.Math.Sqrt(width * width + height * height);
                                                                                                     float scaleFactor = d / (emFontSize * 5f);

                                                                                                     float tan = ((float)height) / width;                
                                                                                                     double radians = System.Math.Atan(tan);
                                                                                                     double degrees = (180 * radians) / System.Math.PI;

                                                                                                     Aspose.Imaging.Matrix transform = new Aspose.Imaging.Matrix();
                                                                                                     transform.Rotate((float)degrees);
                                                                                                     transform.Scale(scaleFactor, scaleFactor);

                                                                                                     // Then, set the transform.
                                                                                                     graphics.SetTransform(transform);

                                                                                                     // Finally, put a watermark (text string of pink color) along the main diagonal.
                                                                                                     graphics.DrawString("WATERMARK", new Aspose.Imaging.Font("Courier New", emFontSize), Aspose.Imaging.Color.LightPink, 0, 0/*, (float)degrees*/);

                                                                                                     // Save the image with watermark to another EMF file.
                                                                                                     using (Aspose.Imaging.FileFormats.Emf.EmfImage scaledEmfImage = graphics.EndRecording())
                                                                                                     {
                                                                                                         scaledEmfImage.Save(dir + "test.scaled.emf");
                                                                                                     }
                                                                                                 }

TranslateTransform(Флотація, Флотація)

Змінює походження координатної системи, прив’язуючи зазначений переклад до трансформаційної матриці цієї Графіки.

public void TranslateTransform(float x, float y)

Parameters

x float

X-координат перекладу

y float

Координати перекладу.

TranslateTransform(плавання, плавання, MatrixOrder)

Змінює походження координатної системи, застосовуючи зазначений переклад до трансформаційної матриці цієї Графіки в зазначеному порядку.

public void TranslateTransform(float x, float y, MatrixOrder order)

Parameters

x float

X-координат перекладу

y float

Координати перекладу.

order MatrixOrder

Визначає, чи перекладається або прикріплюється до матриці трансформації.

 Українська