Class MetafileRecorderGraphics2D

Class MetafileRecorderGraphics2D

nazivni prostor: Aspose.Imaging.FileFormats.Emf.Graphics Sastav: Aspose.Imaging.dll (25.4.0)

Metafili za snimanje grafikona

public abstract class MetafileRecorderGraphics2D

Inheritance

object MetafileRecorderGraphics2D

Derived

EmfRecorderGraphics2D , WmfRecorderGraphics2D

naslijeđeni članovi

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

Properties

BackgroundColor

Uzmite ili postavite boju pozadine.

public Color BackgroundColor { get; set; }

Vrijednost nekretnina

Color

BackgroundMode

Pronađite ili postavite način pozadine.

protected int BackgroundMode { get; set; }

Vrijednost nekretnina

int

Clip

Pronađite ili postavite područje koje ograničava crtanje područja ove grafike

public Region Clip { get; set; }

Vrijednost nekretnina

Region

ClipBounds

Dobivaju se granice klipa.

public RectangleF ClipBounds { get; }

Vrijednost nekretnina

RectangleF

Methods

Clear()

Očisti stanje grafičkog objekta

public void Clear()

DrawArc(Sljedeći članakPen, rektangle, float, float)

Drži luk koji predstavlja dio elipa koji je određen strukturom pravog ugla.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

rect Rectangle

Granične granice elipsima.

startAngle float

Ugledi u stupnjevima mjereni satom od x-axis do početne točke arka.

arcAngle float

Ugledi u stupnjevima mjereni su na satnoj razini od početkaAngle parametara do završetka točke luk.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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(Točka, točka, točka i točka)

Slijedeći Članak Cube bezier.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

pt1 Point

Početak je točka kurve.

pt2 Point

Prva kontrolna točka za kurvicu.

pt3 Point

Druga kontrolna točka za kurvicu.

pt4 Point

Završna točka kurve.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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(Sljedeći Članak Pen, Rectangle)

Izađite iz elipa.

public void DrawEllipse(Pen pen, Rectangle rect)

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

rect Rectangle

Granične granice elipsima.

DrawImage(Sjeverna Koreja, točka)

Napravite određenu sliku, koristeći njezinu izvornu fizičku veličinu, na određenom mjestu.

public void DrawImage(RasterImage image, Point location)

Parameters

image RasterImage

Slike koje treba izrezati.

location Point

Lokacija gornjeg lijevog ugla slične slike.

DrawImage(RasterImage, Rectangle, GrafičkiUnit)

Napravite određeni dio određene slike na određenom mjestu i s određivanom veličinom.

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

Parameters

image RasterImage

Slike koje treba izrezati.

destRect Rectangle

Struktura pravokugla koja određuje lokaciju i veličinu povučenog slika.

srcRect Rectangle

Struktura pravog ugla koja određuje dio predmeta slike za crtanje.

srcUnit GraphicsUnit

Jedinice mjerenja koje koristi srcRect parameter.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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;Podrška samo Pixel jedinica

DrawImage(byte[], Rectangle, GraphicsUnit)

Uklonite sliku.

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

Parameters

imageBytes byte []

Fotografija je bajt.

destRect Rectangle

U pravom smjeru.

srcUnit GraphicsUnit

izvorne jedinice.

DrawImage(Stream, Rectangle i GraphicsUnit)

Uklonite sliku.

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

Parameters

stream Stream

U toku je.

destRect Rectangle

U pravom smjeru.

srcUnit GraphicsUnit

izvorne jedinice.

DrawLine(Svijet, int, int, int, int)

Napravite liniju.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

x1 int

Koordinacija x prvog dijela.

y1 int

Koordinacija prvog točka.

x2 int

Koordinacija x u drugoj točki.

y2 int

Koordinacija u drugoj točki.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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(Točka, točka i točka)

Napravite liniju.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

pt1 Point

Prva točka je.

pt2 Point

Druga je točka.

DrawPath(Sljedeći Članak GraphicsPath)

Napravite put.

public void DrawPath(Pen pen, GraphicsPath path)

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

path GraphicsPath

Cesta za natjecanje.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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(Sljedeći članakPen, rektangle, float, float)

Izađite u peć.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

rect Rectangle

Granične granice elipsima.

startAngle float

Ugledi u stupnjevima mjereni satom od x-axis do početne točke arka.

sweepAngle float

Ugledi u stupnjevima mjereni su na satnoj razini od početkaAngle parametara do završetka točke luk.

DrawPolyCubicBezier(Vrijeme, točka[])

Slijedeći članakPoli kubički bezier.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

points Point []

To su točke.

Exceptions

ArgumentOutOfRangeException

Broj točaka u redoslijedu trebao bi biti više od 3 plus 1, kao što su 4, 7 ili 10.

DrawPolygon(Vrijeme, točka[])

Izađite na poligon.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

points Point []

To su točke.

DrawPolyline(Vrijeme, točka[])

Uklonite polilin.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

points Point []

To su točke.

DrawRectangle(Svijet, int, int, int, int)

Uklonite pravokut.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

x int

X-koordinacija gornjeg lijevog ugla pravog ugla za crtanje.

y int

Y-koordinacija gornjeg lijevog ugla pravog ugla za trčanje.

width int

Širina pravokugla za crtanje.

height int

Visina pravokugla da se izvuče.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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(Sljedeći Članak Pen, Rectangle)

Uklonite pravokut.

public void DrawRectangle(Pen pen, Rectangle rectangle)

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

rectangle Rectangle

Riječ je o izravnom traženju.

DrawString(String, font, boja, int i int)

Uklonite traku.

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

Parameters

string string

To je string.

font Font

Font koji definira tekstni format trake.

color Color

Boja teksta je.

x int

X-koordinacija gornjeg lijevog ugla izrezanog teksta.

y int

Y-koordinacija gornjeg lijevog ugla izrezanog teksta.

Examples

Ovaj primjer pokazuje kako preuzeti EMF sliku iz datoteke i izvući tekstnu traku iznad nje.

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

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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, Boja, int , int, float)

Uklonite traku.

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

Parameters

string string

To je string.

font Font

Font koji definira tekstni format trake.

color Color

Boja teksta je.

x int

X-koordinacija gornjeg lijevog ugla izrezanog teksta.

y int

Y-koordinacija gornjeg lijevog ugla izrezanog teksta.

angle float

Ugla u stupnjevima, između viktora izbjegavanja i x-axisa uređaja.Vektor izbjegavanja paralelno je s osnovnom linijom redovnog teksta.

ExcludeClip(Rectangle)

ažurira područje klipa ove grafike kako bi se isključila područja koja je određena strukturom Rectangle.

public void ExcludeClip(Rectangle rect)

Parameters

rect Rectangle

Rectangle struktura koja određuje rektanglu za isključivanje iz regije klipa.

ExcludeClip(Region)

ažurira područje klipa ove grafike kako bi se isključila područja koja je određena područjem.

public void ExcludeClip(Region region)

Parameters

region Region

Područje koje određuje područje za isključivanje iz područja klipa.

FillEllipse(Šljunčana, Rectangle)

Puni se elips.

public void FillEllipse(Brush brush, Rectangle rect)

Parameters

brush Brush

Brush koji određuje karakteristike punjenja.

rect Rectangle

Granične granice elipsima.

FillPath(Slijedeći Članak Pen, Brush, GraphicsPath)

Puni se put.

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

Parameters

pen Pen

Pen koji određuje boju, širinu i stil figure.

brush Brush

Brush koji određuje karakteristike punjenja.

path GraphicsPath

Put za ispunjavanje.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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(Prskanje, rektangle, float, float)

Napunite pješačenje.

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

Parameters

brush Brush

Brush koji određuje karakteristike punjenja.

rect Rectangle

Granične granice elipsima.

startAngle float

Ugledi u stupnjevima mjereni satom od x-axis do početne točke arka.

sweepAngle float

Ugledi u stupnjevima mjereni su na satnoj razini od početkaAngle parametara do završetka točke luk.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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(Šipka, točka[])

Puni se poligon.

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

Parameters

brush Brush

Brush koji određuje karakteristike punjenja.

points Point []

To su točke.

FillPolygon(Šipka, točka[], Svijet FillMode)

Puni se poligon.

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

Parameters

brush Brush

Brush koji određuje karakteristike punjenja.

points Point []

To su točke.

fillMode FillMode

Popunjajući način.

FillRectangle(Šljunčana, Rectangle)

Puni se pravokugli.

public void FillRectangle(Brush brush, Rectangle rectangle)

Parameters

brush Brush

Brush koji određuje karakteristike punjenja.

rectangle Rectangle

Pravo mjesto za ispunjavanje.

Examples

Ovaj primjer pokazuje kako stvoriti WMF sliku i crtati neke geometrijske oblike pomoću 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");
                                                                                                                   }

Ovaj primjer pokazuje kako stvoriti EMF sliku i izrezati neke geometrijske oblike na njemu pomoću 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()

Svijet se mijenja.

public Matrix GetTransform()

Returns

Matrix

To je transformacija matrice.

IntersectClip(RectangleF)

ažurira područje klipa ove grafike na prekretanje trenutačnog klipskog područja i određenu strukturu Rectangle.

public void IntersectClip(RectangleF rect)

Parameters

rect RectangleF

Rectangle struktura da se međusobno povezuje s trenutačnim područjem klipa.

IntersectClip(Region)

ažurira područje klipa ove grafike na prekretanje trenutačnog područja klipu i određene regije.

public void IntersectClip(Region region)

Parameters

region Region

Svijet će se međusobno povezati s sadašnjom regijom.

MultiplyTransform(Matrix)

Množi svjetsku transformaciju ove grafike i određuje Matrix.

public void MultiplyTransform(Matrix matrix)

Parameters

matrix Matrix

Matrix koji množi svjetsku transformaciju.

MultiplyTransform(Matrix i MatrixOrder)

Množi globalnu transformaciju ove grafike i određuje matricu u određenom redoslijedu.

public void MultiplyTransform(Matrix matrix, MatrixOrder order)

Parameters

matrix Matrix

Matrix koji množi svjetsku transformaciju.

order MatrixOrder

U redoslijedu razmnožavanja.

ResetClip()

Obnavlja se klip.

public void ResetClip()

RotateTransform(float)

Primjenjuje određenu rotaciju na transformacijsku matricu ove grafike.

public void RotateTransform(float angle)

Parameters

angle float

ugla rotacije u stupnjevu.

RotateTransform(Sljedeći članakSljedeći članakSljedeći članakSljedeći članakMatrixOrder)

Primjenjuje određenu rotaciju na transformacijsku matricu ove grafike u određenom redoslijedu.

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

Parameters

angle float

ugla rotacije u stupnjevu.

center PointF

To je rotacijski centar.

order MatrixOrder

određuje je li rotacija dodijeljena ili prepenjena na transformaciju matrice.

ScaleTransform(plovidba, plovidba)

Primjenjuje određenu operaciju skaliranja na transformacijsku matricu ove grafike prijenosom na pretvaranje matrice objekta.

public void ScaleTransform(float sx, float sy)

Parameters

sx float

Razmjerni faktor u smjeru x.

sy float

Razmjerni faktor u smjeru i.

ScaleTransform(plovidba, plovidba, MatrixOrder)

Primjenjuje određenu operaciju skaliranja na transformacijsku matricu ove grafike u određenom redoslijedu.

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

Parameters

sx float

Razmjerni faktor u smjeru x.

sy float

Razmjerni faktor u smjeru i.

order MatrixOrder

To određuje je li operacija skaliranja prepenjena ili prilagođena transformacijskoj matrici.

SetTransform(Matrix)

Postavlja se transformacija.

public void SetTransform(Matrix transform)

Parameters

transform Matrix

Nova transformacijska matrica.

Examples

Ovaj primjer pokazuje kako preuzeti EMF sliku iz datoteke i izvući tekstnu traku iznad nje.

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(plovidba, plovidba)

Promijeniti podrijetlo koordinatnog sustava prijenosom određenog prijevoda na transformacijsku matricu ove grafike.

public void TranslateTransform(float x, float y)

Parameters

x float

To je x-koordinat prijevoda.

y float

Koordinacija i prijevoda.

TranslateTransform(plovidba, plovidba, MatrixOrder)

Promijeniti podrijetlo koordinatnog sustava primjenom određenog prijevoda na transformacijsku matricu ove Grafičke u navedenom redoslijedu.

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

Parameters

x float

To je x-koordinat prijevoda.

y float

Koordinacija i prijevoda.

order MatrixOrder

To određuje je li prevod prepenjen ili dodan transformacijskoj matrici.

 Hrvatski