Class WmfRecorderGraphics2D
Nombre del espacio: Aspose.Imaging.FileFormats.Wmf.Graphics Asamblea: Aspose.Imaging.dll (25.4.0)
El registro de WMF.
public sealed class WmfRecorderGraphics2D : MetafileRecorderGraphics2D
Inheritance
object ← MetafileRecorderGraphics2D ← WmfRecorderGraphics2D
Miembros heredados
MetafileRecorderGraphics2D.Clear() ,y, MetafileRecorderGraphics2D.DrawArc(Pen, Rectangle, float, float) ,y, MetafileRecorderGraphics2D.DrawCubicBezier(Pen, Point, Point, Point, Point) ,y, MetafileRecorderGraphics2D.DrawPolyCubicBezier(Pen, Point[]) ,y, MetafileRecorderGraphics2D.DrawEllipse(Pen, Rectangle) ,y, MetafileRecorderGraphics2D.FillEllipse(Brush, Rectangle) ,y, MetafileRecorderGraphics2D.DrawImage(RasterImage, Point) ,y, MetafileRecorderGraphics2D.DrawImage(RasterImage, Rectangle, Rectangle, GraphicsUnit) ,y, MetafileRecorderGraphics2D.DrawImage(byte[], Rectangle, GraphicsUnit) ,y, MetafileRecorderGraphics2D.DrawImage(Stream, Rectangle, GraphicsUnit) ,y, MetafileRecorderGraphics2D.DrawLine(Pen, int, int, int, int) ,y, MetafileRecorderGraphics2D.DrawLine(Pen, Point, Point) ,y, MetafileRecorderGraphics2D.DrawPolyline(Pen, Point[]) ,y, MetafileRecorderGraphics2D.DrawPath(Pen, GraphicsPath) ,y, MetafileRecorderGraphics2D.FillPath(Pen, Brush, GraphicsPath) ,y, MetafileRecorderGraphics2D.DrawPie(Pen, Rectangle, float, float) ,y, MetafileRecorderGraphics2D.FillPie(Brush, Rectangle, float, float) ,y, MetafileRecorderGraphics2D.DrawPolygon(Pen, Point[]) ,y, MetafileRecorderGraphics2D.FillPolygon(Brush, Point[]) ,y, MetafileRecorderGraphics2D.FillPolygon(Brush, Point[], FillMode) ,y, MetafileRecorderGraphics2D.DrawRectangle(Pen, int, int, int, int) ,y, MetafileRecorderGraphics2D.DrawRectangle(Pen, Rectangle) ,y, MetafileRecorderGraphics2D.FillRectangle(Brush, Rectangle) ,y, MetafileRecorderGraphics2D.DrawString(string, Font, Color, int, int) ,y, MetafileRecorderGraphics2D.DrawString(string, Font, Color, int, int, float) ,y, MetafileRecorderGraphics2D.ExcludeClip(Rectangle) ,y, MetafileRecorderGraphics2D.ExcludeClip(Region) ,y, MetafileRecorderGraphics2D.IntersectClip(RectangleF) ,y, MetafileRecorderGraphics2D.IntersectClip(Region) ,y, MetafileRecorderGraphics2D.ResetClip() ,y, MetafileRecorderGraphics2D.MultiplyTransform(Matrix) ,y, MetafileRecorderGraphics2D.MultiplyTransform(Matrix, MatrixOrder) ,y, MetafileRecorderGraphics2D.TranslateTransform(float, float) ,y, MetafileRecorderGraphics2D.TranslateTransform(float, float, MatrixOrder) ,y, MetafileRecorderGraphics2D.RotateTransform(float) ,y, MetafileRecorderGraphics2D.RotateTransform(float, PointF, MatrixOrder) ,y, MetafileRecorderGraphics2D.ScaleTransform(float, float) ,y, MetafileRecorderGraphics2D.ScaleTransform(float, float, MatrixOrder) ,y, MetafileRecorderGraphics2D.GetTransform() ,y, MetafileRecorderGraphics2D.SetTransform(Matrix) ,y, MetafileRecorderGraphics2D.Clip ,y, MetafileRecorderGraphics2D.ClipBounds ,y, MetafileRecorderGraphics2D.BackgroundColor ,y, object.GetType() ,y, object.ToString() ,y, object.Equals(object?) ,y, object.Equals(object?, object?) ,y, object.ReferenceEquals(object?, object?) ,y, object.GetHashCode()
Constructors
WmfRecorderGráficos2D(El rectángulo, int)
Inicia una nueva instancia de la clase Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D.
public WmfRecorderGraphics2D(Rectangle frame, int inch)
Parameters
frame
Rectangle
Destination rectangle, medido en twips, para mostrar el metáfil.
inch
int
El número de píxeles por pulgón.
Examples
Este ejemplo muestra cómo crear una imagen WMF y dibujar algunas formas geométricas utilizando 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");
}
Properties
BackgroundMode
Obtenga o establece el modo de fondo.
public WmfMixMode BackgroundMode { get; set; }
Valor de la propiedad
Methods
EndRecording()
Fin de la grabación.
public WmfImage EndRecording()
Returns
La imagen del resultado.
Examples
Este ejemplo muestra cómo crear una imagen WMF y dibujar algunas formas geométricas utilizando 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");
}
FromWmfImage(WmfImage)
Obtenga una instancia del registro Wmf para la imagen Wmf existente.
public static WmfRecorderGraphics2D FromWmfImage(WmfImage wmfImage)
Parameters
wmfImage
WmfImage
La imagen de Wmf para obtener un recorridor.
Returns
Un ejemplo de la clase Aspose.Imaging.FileFormats.Wmf.Graphics.WmfRecorderGraphics2D.