Class MetafileRecorderGraphics2D

Class MetafileRecorderGraphics2D

Il nome: Aspose.Imaging.FileFormats.Emf.Graphics Assemblea: Aspose.Imaging.dll (25.4.0)

La grafica dei metafili

public abstract class MetafileRecorderGraphics2D

Inheritance

object MetafileRecorderGraphics2D

Derived

EmfRecorderGraphics2D , WmfRecorderGraphics2D

I membri ereditari

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

Properties

BackgroundColor

Riceve o impone il colore del background.

public Color BackgroundColor { get; set; }

Valore di proprietà

Color

BackgroundMode

Ottenere o impostare la modalità di sfondo.

protected int BackgroundMode { get; set; }

Valore di proprietà

int

Clip

Ottieni o impostare una Regione che limita la regione di disegno di questo grafico

public Region Clip { get; set; }

Valore di proprietà

Region

ClipBounds

Ricevi i limiti del clip.

public RectangleF ClipBounds { get; }

Valore di proprietà

RectangleF

Methods

Clear()

Chiarire lo stato dell’oggetto grafico

public void Clear()

DrawArc(Pen, rettangolo, float, float)

Traccia un arco che rappresenta una porzione di un ellipo specificato da una struttura rettangolare.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

rect Rectangle

I confini dell’ellipsi.

startAngle float

L’angolo in gradi misurato in modo orario dall’asse x al punto di partenza dell’arca.

arcAngle float

L’angolo in gradi misurato in modo orario dall’inizioParametro Angolo fino alla fine del punto dell’arca.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(Il punto, il punto, il punto)

Rimuovere il cubico bezier.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

pt1 Point

Il punto di partenza della curva.

pt2 Point

Il primo punto di controllo per la curva.

pt3 Point

Il secondo punto di controllo per la curva.

pt4 Point

Il punto di fine della curva.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(Pen, Rettangolo)

Rimuovere l’ellipso.

public void DrawEllipse(Pen pen, Rectangle rect)

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

rect Rectangle

I confini dell’ellipsi.

DrawImage(Il punto, il punto)

Ritratta l’immagine specificata, utilizzando la sua dimensione fisica originale, nella posizione specifica.

public void DrawImage(RasterImage image, Point location)

Parameters

image RasterImage

L’immagine da disegnare.

location Point

La posizione della parte superiore sinistra dell’immagine ritratta.

DrawImage(RasterImage, Rectangle, GraphicsUnit)

Ritratta la porzione specifica dell’immagine specificata nella località e con le dimensioni specificate.

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

Parameters

image RasterImage

L’immagine da disegnare.

destRect Rectangle

Struttura rettangolare che specifica la posizione e la dimensione dell’immagine ritratta.

srcRect Rectangle

Struttura rettangolare che specifica la parte dell’oggetto immagine da disegnare.

srcUnit GraphicsUnit

Le unità di misura utilizzate dal parametro srcRect.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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;Supporta solo unità Pixel

DrawImage(di byte[ ], Rectangle, GraphicsUnit)

Rimuovere l’immagine.

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

Parameters

imageBytes byte [ ]

L’immagine è byte.

destRect Rectangle

La retta destra.

srcUnit GraphicsUnit

Unità di sorgente.

DrawImage(Strumento, Rectangle, GraphicsUnit)

Rimuovere l’immagine.

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

Parameters

stream Stream

Il flusso .

destRect Rectangle

La retta destra.

srcUnit GraphicsUnit

Unità di sorgente.

DrawLine(Pen, int, int, int, int)

Traccia la linea.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

x1 int

Il coordinato x del primo punto.

y1 int

Il coordinato del primo punto.

x2 int

Il coordinato x del secondo punto.

y2 int

Il coordinato del secondo punto.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(Il punto, il punto)

Traccia la linea.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

pt1 Point

Il primo punto.

pt2 Point

Il secondo punto.

DrawPath(Giochi, GraphicsPath)

Traccia il percorso.

public void DrawPath(Pen pen, GraphicsPath path)

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

path GraphicsPath

Il cammino per disegnare.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(Pen, rettangolo, float, float)

Traccia il piede.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

rect Rectangle

I confini dell’ellipsi.

startAngle float

L’angolo in gradi misurato in modo orario dall’asse x al punto di partenza dell’arca.

sweepAngle float

L’angolo in gradi misurato in modo orario dall’inizioParametro Angolo fino alla fine del punto dell’arca.

DrawPolyCubicBezier(Il punto, punto[])

Rimuovere il polio cubico bezier.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

points Point [ ]

I punti .

Exceptions

ArgumentOutOfRangeException

Il numero di punti in ordine dovrebbe essere multiplo di 3 plus 1, come 4, 7 o 10.

DrawPolygon(Il punto, punto[])

Rimuovere il poligono.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

points Point [ ]

I punti .

DrawPolyline(Il punto, punto[])

Rimuovere la polline.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

points Point [ ]

I punti .

DrawRectangle(Pen, int, int, int, int)

Rimuovere il rectangolo.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

x int

Il coordinato x dell’angolo superiore a sinistra del rectangolo da disegnare.

y int

Il coordinato y dell’angolo superiore a sinistra del rectangolo per tirare.

width int

La larghezza del rectangolo da disegnare.

height int

L’altezza del rectangolo da disegnare.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(Pen, Rettangolo)

Rimuovere il rectangolo.

public void DrawRectangle(Pen pen, Rectangle rectangle)

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

rectangle Rectangle

Il rectangolo da disegnare.

DrawString(String, Fonte, Colore, Int, int)

Rimuovere la stringa.

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

Parameters

string string

Il strato .

font Font

Fonte che definisce il formato del testo della riga.

color Color

Il colore del testo.

x int

Il coordinato x dell’angolo superiore sinistro del testo ritratto.

y int

Il coordinato y dell’angolo superiore a sinistra del testo ritratto.

Examples

Questo esempio mostra come caricare un’immagine EMF da un file e disegnare una riga di testo sopra di esso.

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");
                                                                                                     }
                                                                                                 }

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(String, Font, Colore, Int, int, Float)

Rimuovere la stringa.

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

Parameters

string string

Il strato .

font Font

Fonte che definisce il formato del testo della riga.

color Color

Il colore del testo.

x int

Il coordinato x dell’angolo superiore sinistro del testo ritratto.

y int

Il coordinato y dell’angolo superiore a sinistra del testo ritratto.

angle float

L’angolo in gradi, tra il vettore di scappamento e l’asse x del dispositivo.Il vettore di escape è parallelo alla linea di base di una riga di testo.

ExcludeClip(Rectangle)

Aggiornare la regione clip di questo grafico per escludere l’area specificata da una struttura Rectangle.

public void ExcludeClip(Rectangle rect)

Parameters

rect Rectangle

Struttura rettangolare che specifica la rettanga per escludere dalla regione del clip.

ExcludeClip(Region)

Aggiornare la regione clip di questo grafico per escludere l’area specificata da una Regione.

public void ExcludeClip(Region region)

Parameters

region Region

Regione che specifica la regione per escludere dalla zona clip.

FillEllipse(Spazzolino, Rectangle)

Si riempie l’ellipso.

public void FillEllipse(Brush brush, Rectangle rect)

Parameters

brush Brush

Spazzolino che determina le caratteristiche del riempimento.

rect Rectangle

I confini dell’ellipsi.

FillPath(Pen, Brush e GraphicsPath)

Si riempie il percorso.

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

Parameters

pen Pen

Pen che determina il colore, la larghezza e lo stile della figura.

brush Brush

Spazzolino che determina le caratteristiche del riempimento.

path GraphicsPath

Il cammino per riempire.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(Spazzolino, Rectangle, Float, Float)

Si riempie il piede.

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

Parameters

brush Brush

Spazzolino che determina le caratteristiche del riempimento.

rect Rectangle

I confini dell’ellipsi.

startAngle float

L’angolo in gradi misurato in modo orario dall’asse x al punto di partenza dell’arca.

sweepAngle float

L’angolo in gradi misurato in modo orario dall’inizioParametro Angolo fino alla fine del punto dell’arca.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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(Il punto, il punto[])

Si riempie il poligono.

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

Parameters

brush Brush

Spazzolino che determina le caratteristiche del riempimento.

points Point [ ]

I punti .

FillPolygon(Il punto, il punto[ ], di FillMode)

Si riempie il poligono.

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

Parameters

brush Brush

Spazzolino che determina le caratteristiche del riempimento.

points Point [ ]

I punti .

fillMode FillMode

La modalità di riempimento.

FillRectangle(Spazzolino, Rectangle)

Riempire il rectangolo.

public void FillRectangle(Brush brush, Rectangle rectangle)

Parameters

brush Brush

Spazzolino che determina le caratteristiche del riempimento.

rectangle Rectangle

Il rectangolo per riempire.

Examples

Questo esempio mostra come creare un’immagine WMF e disegnare alcune forme geometriche utilizzando 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");
                                                                                                                   }

Questo esempio mostra come creare un’immagine EMF e disegnare alcune forme geometriche su di essa utilizzando 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()

Il mondo si trasforma.

public Matrix GetTransform()

Returns

Matrix

La trasformazione della matrice.

IntersectClip(di Rectangle)

Aggiornare la regione del clip di questo grafico alla intersezione dell’attuale Regione dei clip e alla struttura Rectangle specificata.

public void IntersectClip(RectangleF rect)

Parameters

rect RectangleF

Struttura rettangolare per intersectare con la regione clip corrente.

IntersectClip(Region)

Aggiornare la regione del clip di questo grafico alla intersezione dell’attuale area del video e della Regione specificata.

public void IntersectClip(Region region)

Parameters

region Region

La regione deve intersectarsi con l’attuale Regione.

MultiplyTransform(Matrix)

Moltiplica la trasformazione del mondo di questa grafica e specifica la matrice.

public void MultiplyTransform(Matrix matrix)

Parameters

matrix Matrix

La matrice che moltiplica la trasformazione del mondo.

MultiplyTransform(di Matrix, MatrixOrder)

Moltiplica la trasformazione del mondo di questa grafica e specifica la matrice nell’ordine specificato.

public void MultiplyTransform(Matrix matrix, MatrixOrder order)

Parameters

matrix Matrix

La matrice che moltiplica la trasformazione del mondo.

order MatrixOrder

L’ordine della moltiplicazione.

ResetClip()

Ripristinare il clip.

public void ResetClip()

RotateTransform(flotta)

Applica la rotazione specificata alla matrice di trasformazione di questa grafica.

public void RotateTransform(float angle)

Parameters

angle float

Angolo di rotazione in gradi.

RotateTransform(Sito ufficiale: PointF, MatrixOrder)

Applica la rotazione specificata alla matrice di trasformazione di questa grafica nell’ordine specificato.

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

Parameters

angle float

Angolo di rotazione in gradi.

center PointF

Il centro di rotazione.

order MatrixOrder

Determinare se la rotazione è appendita o prependita alla trasformazione della matrice.

ScaleTransform(La flotta, la flotta)

Applicare l’operazione di scalazione specificata alla matrice di trasformazione di questa grafica premendola alla matrix di transformazione dell’oggetto.

public void ScaleTransform(float sx, float sy)

Parameters

sx float

Il fattore di scala nella direzione x.

sy float

Il fattore di scala nella direzione y.

ScaleTransform(Il flusso, il flusso, MatrixOrder)

Applica l’operazione di scalazione specificata alla matrice di trasformazione di questa grafica nell’ordine specificato.

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

Parameters

sx float

Il fattore di scala nella direzione x.

sy float

Il fattore di scala nella direzione y.

order MatrixOrder

Determinare se l’operazione di scalazione è prependita o appendita alla matrice di trasformazione.

SetTransform(Matrix)

Imposta la trasformazione.

public void SetTransform(Matrix transform)

Parameters

transform Matrix

La nuova matrice di trasformazione.

Examples

Questo esempio mostra come caricare un’immagine EMF da un file e disegnare una riga di testo sopra di esso.

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(La flotta, la flotta)

Modifica l’origine del sistema di coordinate premendo la traduzione specifica alla matrice di trasformazione di questa grafica.

public void TranslateTransform(float x, float y)

Parameters

x float

Il coordinato x della traduzione.

y float

L’e-coordinato della traduzione.

TranslateTransform(Il flusso, il flusso, MatrixOrder)

Modifica l’origine del sistema di coordinate applicando la traduzione specificata alla matrice di trasformazione di questa grafica nell’ordine specificato.

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

Parameters

x float

Il coordinato x della traduzione.

y float

L’e-coordinato della traduzione.

order MatrixOrder

Determinare se la traduzione è prependita o appendita alla matrice di trasformazione.

 Italiano