Class MetafileRecorderGraphics2D
De naam: Aspose.Imaging.FileFormats.Emf.Graphics Verzameling: Aspose.Imaging.dll (25.4.0)
De metafileren opnemen graphics
public abstract class MetafileRecorderGraphics2D
Inheritance
object ← MetafileRecorderGraphics2D
Derived
EmfRecorderGraphics2D , WmfRecorderGraphics2D
Geëerbiede leden
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Properties
BackgroundColor
Geeft of bepaalt de kleur van de achtergrond.
public Color BackgroundColor { get; set; }
Eigendomswaarde
BackgroundMode
Geeft of instelt de achtergrondmodus.
protected int BackgroundMode { get; set; }
Eigendomswaarde
Clip
Geeft of stelt een regio die de draairegio van deze grafiek beperkt
public Region Clip { get; set; }
Eigendomswaarde
ClipBounds
Krijg de clip grenzen.
public RectangleF ClipBounds { get; }
Eigendomswaarde
Methods
Clear()
Verduidelijkt de toestand van het grafische object
public void Clear()
DrawArc(Pen, rectangle, float, float)
Draai een arc die een portie van een ellipse vertegenwoordigt die wordt aangegeven door een rectangle structuur.
public void DrawArc(Pen pen, Rectangle rect, float startAngle, float arcAngle)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
rect
Rectangle
De grenzen van de ellipses.
startAngle
float
Winkel in graden gemeten klokwijze van de x-axis tot het uitgangspunt van de arc.
arcAngle
float
Winkel in graden gemeten klokwijze van de startWinkel parameter tot het eindpunt van het arc.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van 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(Pijn, punt, punt en punt)
De kubieke bezier draaien.
public void DrawCubicBezier(Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
pt1
Point
Het beginpunt van de curve.
pt2
Point
Het eerste controlepunt voor de curve.
pt3
Point
Het tweede controlepunt voor de curve.
pt4
Point
Het eindpunt van de curve.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van EmfRecorderGraphics2D.
string dir = "c:\\temp\\";
// The image size in pixels
int deviceWidth = 600;
int deviceHeight = 400;
// The image size in millimiters
int deviceWidthMm = (int)(deviceWidth / 100f);
int deviceHeightMm = (int)(deviceHeight / 100f);
Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);
// Create a EMF image.
Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
frame,
new Aspose.Imaging.Size(deviceWidth, deviceHeight),
new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));
// Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);
// Fill a rectangle with the color of white-smoke.
graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));
// Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);
// Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);
// Fill an arc
graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);
// Draw a cubic bezier using a 2-pixel-wide red pen.
graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(200, 133),
new Aspose.Imaging.Point(400, 166),
new Aspose.Imaging.Point(600, 400));
// Draw a raster image of the specified size at the specified location.
// The image is scaled to fit the desired rectangle.
using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
{
graphics.DrawImage(imageToDraw,
new Aspose.Imaging.Rectangle(400, 200, 100, 50),
new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight),
Aspose.Imaging.GraphicsUnit.Pixel);
}
// Draw a text string
graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);
// Create a path to fill
Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
figureToFill.IsClosed = true;
Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
pathToFill.AddFigure(figureToFill);
figureToFill.AddShapes(new Shape[]
{
new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
new Aspose.Imaging.Shapes.BezierShape(
new Aspose.Imaging.PointF[]
{
new Aspose.Imaging.PointF(300, 200),
new Aspose.Imaging.PointF(400, 200),
new Aspose.Imaging.PointF(500, 100),
new Aspose.Imaging.PointF(600, 200),
}),
new Aspose.Imaging.Shapes.PolygonShape(
new Aspose.Imaging.PointF[]
{
new Aspose.Imaging.PointF(300, 100),
}),
new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
});
// Fill the path using a yellow brush and a green pen to draw outline
graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);
// Create a path to draw
Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
pathToDraw.AddFigure(figureToDraw);
figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
{
new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
});
// Draw the path using a 5-pixel-wide orange pen.
graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);
// In order to rasterize SVG we need to specify rasterization options.
Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
saveOptions.VectorRasterizationOptions = rasterizationOptions;
// Get the final WMF image which includes all drawing commands
using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
{
emfImage.Save(dir + "test.output.emf");
}
DrawEllipse(Pen, rectangle)
Draai de ellipse.
public void DrawEllipse(Pen pen, Rectangle rect)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
rect
Rectangle
De grenzen van de ellipses.
DrawImage(Hoofdstukken, Point)
Draag de aangegeven afbeelding, met behulp van zijn oorspronkelijke fysieke grootte, op de gegeven locatie.
public void DrawImage(RasterImage image, Point location)
Parameters
image
RasterImage
Het beeld om te draaien.
location
Point
De locatie van de bovenste linker hoek van het getransporteerde beeld.
DrawImage(RasterImage, Rectangle en GraphicsUnit)
Draai de aangegeven portie van de getoonde afbeelding op de gegeven locatie en met de gemotiveerde grootte.
public void DrawImage(RasterImage image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
Parameters
image
RasterImage
Het beeld om te draaien.
destRect
Rectangle
Rectangle structuur die de locatie en de grootte van de getransporteerde afbeelding bepaalt.
srcRect
Rectangle
Rectangle structuur die het gedeelte van het beeldobject om te trekken bepaalt.
srcUnit
GraphicsUnit
De eenheden van de meting die door de srcRect-parameters worden gebruikt.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van 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
srcUnit;Support slechts Pixel-eenheid
DrawImage(byte[], Rectangle, GraphicsUnit)
Draai de afbeelding.
public void DrawImage(byte[] imageBytes, Rectangle destRect, GraphicsUnit srcUnit)
Parameters
imageBytes
byte
[]
De afbeelding bytes.
destRect
Rectangle
De dest rect.
srcUnit
GraphicsUnit
De bron eenheid.
DrawImage(Stream, Rectangle, GraphicsUnit)
Draai de afbeelding.
public void DrawImage(Stream stream, Rectangle destRect, GraphicsUnit srcUnit)
Parameters
stream
Stream
De stroom.
destRect
Rectangle
De dest rect.
srcUnit
GraphicsUnit
De bron eenheid.
DrawLine(Pen, int, int, int, int)
Draai de lijn.
public void DrawLine(Pen pen, int x1, int y1, int x2, int y2)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
x1
int
De x-coördinatie van het eerste punt.
y1
int
De coördinatie van het eerste punt.
x2
int
De x-coördinatie van het tweede punt.
y2
int
De coördinatie van het tweede punt.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van 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(Pijn, punt en punt)
Draai de lijn.
public void DrawLine(Pen pen, Point pt1, Point pt2)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
pt1
Point
Het eerste punt.
pt2
Point
Het tweede punt.
DrawPath(Pijn, GraphicsPath)
Draai de weg.
public void DrawPath(Pen pen, GraphicsPath path)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
path
GraphicsPath
De weg om te trekken.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van EmfRecorderGraphics2D.
string dir = "c:\\temp\\";
// The image size in pixels
int deviceWidth = 600;
int deviceHeight = 400;
// The image size in millimiters
int deviceWidthMm = (int)(deviceWidth / 100f);
int deviceHeightMm = (int)(deviceHeight / 100f);
Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);
// Create a EMF image.
Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
frame,
new Aspose.Imaging.Size(deviceWidth, deviceHeight),
new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));
// Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);
// Fill a rectangle with the color of white-smoke.
graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));
// Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);
// Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);
// Fill an arc
graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);
// Draw a cubic bezier using a 2-pixel-wide red pen.
graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(200, 133),
new Aspose.Imaging.Point(400, 166),
new Aspose.Imaging.Point(600, 400));
// Draw a raster image of the specified size at the specified location.
// The image is scaled to fit the desired rectangle.
using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
{
graphics.DrawImage(imageToDraw,
new Aspose.Imaging.Rectangle(400, 200, 100, 50),
new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight),
Aspose.Imaging.GraphicsUnit.Pixel);
}
// Draw a text string
graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);
// Create a path to fill
Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
figureToFill.IsClosed = true;
Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
pathToFill.AddFigure(figureToFill);
figureToFill.AddShapes(new Shape[]
{
new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
new Aspose.Imaging.Shapes.BezierShape(
new Aspose.Imaging.PointF[]
{
new Aspose.Imaging.PointF(300, 200),
new Aspose.Imaging.PointF(400, 200),
new Aspose.Imaging.PointF(500, 100),
new Aspose.Imaging.PointF(600, 200),
}),
new Aspose.Imaging.Shapes.PolygonShape(
new Aspose.Imaging.PointF[]
{
new Aspose.Imaging.PointF(300, 100),
}),
new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
});
// Fill the path using a yellow brush and a green pen to draw outline
graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);
// Create a path to draw
Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
pathToDraw.AddFigure(figureToDraw);
figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
{
new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
});
// Draw the path using a 5-pixel-wide orange pen.
graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);
// In order to rasterize SVG we need to specify rasterization options.
Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
saveOptions.VectorRasterizationOptions = rasterizationOptions;
// Get the final WMF image which includes all drawing commands
using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
{
emfImage.Save(dir + "test.output.emf");
}
DrawPie(Pen, rectangle, float, float)
Draai de pie.
public void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
rect
Rectangle
De grenzen van de ellipses.
startAngle
float
Winkel in graden gemeten klokwijze van de x-axis tot het uitgangspunt van de arc.
sweepAngle
float
Winkel in graden gemeten klokwijze van de startWinkel parameter tot het eindpunt van het arc.
DrawPolyCubicBezier(Het punt, punt[])
Draai de poly-cubische bezier.
public void DrawPolyCubicBezier(Pen pen, Point[] points)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
points
Point
[]
De punten .
Exceptions
Het aantal punten in de volgorde moet een meervoud zijn van 3 plus 1, zoals 4, 7 of 10.
DrawPolygon(Het punt, punt[])
Verwijder het polygon.
public void DrawPolygon(Pen pen, Point[] points)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
points
Point
[]
De punten .
DrawPolyline(Het punt, punt[])
Verwijder de polyline.
public void DrawPolyline(Pen pen, Point[] points)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
points
Point
[]
De punten .
DrawRectangle(Pen, int, int, int, int)
Draai de rectangel.
public void DrawRectangle(Pen pen, int x, int y, int width, int height)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
x
int
De x-coordinaat van de bovenste linker hoek van de rectangle om te trekken.
y
int
De y-koordinaat van de bovenste linker hoek van de rectangle om te trekken.
width
int
De breedte van de rectangle om te trekken.
height
int
De hoogte van de rectangle om te trekken.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van EmfRecorderGraphics2D.
string dir = "c:\\temp\\";
// The image size in pixels
int deviceWidth = 600;
int deviceHeight = 400;
// The image size in millimiters
int deviceWidthMm = (int)(deviceWidth / 100f);
int deviceHeightMm = (int)(deviceHeight / 100f);
Aspose.Imaging.Rectangle frame = new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight);
// Create a EMF image.
Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D graphics =
new Aspose.Imaging.FileFormats.Emf.Graphics.EmfRecorderGraphics2D(
frame,
new Aspose.Imaging.Size(deviceWidth, deviceHeight),
new Aspose.Imaging.Size(deviceWidthMm, deviceHeightMm));
// Draw a black rectangle along the image borders using a 1-pixel-wide black pen.
graphics.DrawRectangle(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Black, 1), 0, 0, deviceWidth, deviceHeight);
// Fill a rectangle with the color of white-smoke.
graphics.FillRectangle(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.WhiteSmoke), new Aspose.Imaging.Rectangle(10, 10, 580, 380));
// Draw two diagonal lines using a 1-pixel-wide darkgreen pen.
graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, 0, deviceWidth, deviceHeight);
graphics.DrawLine(new Aspose.Imaging.Pen(Aspose.Imaging.Color.DarkGreen, 1), 0, deviceHeight, deviceWidth, 0);
// Draw an arc within the rectangle {0, 0, 200, 200} using a 2-pixel-wide blue pen.
graphics.DrawArc(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Blue, 2), new Aspose.Imaging.Rectangle(0, 0, 200, 200), 90, 270);
// Fill an arc
graphics.FillPie(new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.LightSkyBlue), new Aspose.Imaging.Rectangle(0, 0, 150, 150), 90, 270);
// Draw a cubic bezier using a 2-pixel-wide red pen.
graphics.DrawCubicBezier(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Red, 2),
new Aspose.Imaging.Point(0, 0),
new Aspose.Imaging.Point(200, 133),
new Aspose.Imaging.Point(400, 166),
new Aspose.Imaging.Point(600, 400));
// Draw a raster image of the specified size at the specified location.
// The image is scaled to fit the desired rectangle.
using (Aspose.Imaging.RasterImage imageToDraw = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(dir + "sample.bmp"))
{
graphics.DrawImage(imageToDraw,
new Aspose.Imaging.Rectangle(400, 200, 100, 50),
new Aspose.Imaging.Rectangle(0, 0, deviceWidth, deviceHeight),
Aspose.Imaging.GraphicsUnit.Pixel);
}
// Draw a text string
graphics.DrawString("Hello World!", new Aspose.Imaging.Font("Arial", 48, Aspose.Imaging.FontStyle.Regular), Aspose.Imaging.Color.DarkRed, 200, 300);
// Create a path to fill
Aspose.Imaging.Figure figureToFill = new Aspose.Imaging.Figure();
figureToFill.IsClosed = true;
Aspose.Imaging.GraphicsPath pathToFill = new Aspose.Imaging.GraphicsPath();
pathToFill.AddFigure(figureToFill);
figureToFill.AddShapes(new Shape[]
{
new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.Rectangle(400, 0, 200, 100), 45, 300),
new Aspose.Imaging.Shapes.BezierShape(
new Aspose.Imaging.PointF[]
{
new Aspose.Imaging.PointF(300, 200),
new Aspose.Imaging.PointF(400, 200),
new Aspose.Imaging.PointF(500, 100),
new Aspose.Imaging.PointF(600, 200),
}),
new Aspose.Imaging.Shapes.PolygonShape(
new Aspose.Imaging.PointF[]
{
new Aspose.Imaging.PointF(300, 100),
}),
new Aspose.Imaging.Shapes.RectangleShape(new Aspose.Imaging.RectangleF(0, 100, 200, 200)),
});
// Fill the path using a yellow brush and a green pen to draw outline
graphics.FillPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Green, 2), new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Yellow), pathToFill);
// Create a path to draw
Aspose.Imaging.GraphicsPath pathToDraw = new Aspose.Imaging.GraphicsPath();
Aspose.Imaging.Figure figureToDraw = new Aspose.Imaging.Figure();
pathToDraw.AddFigure(figureToDraw);
figureToDraw.AddShapes(new Aspose.Imaging.Shape[]
{
new Aspose.Imaging.Shapes.ArcShape(new Aspose.Imaging.RectangleF(200, 200, 200, 200), 0, 360),
});
// Draw the path using a 5-pixel-wide orange pen.
graphics.DrawPath(new Aspose.Imaging.Pen(Aspose.Imaging.Color.Orange, 5), pathToDraw);
// In order to rasterize SVG we need to specify rasterization options.
Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
saveOptions.VectorRasterizationOptions = rasterizationOptions;
// Get the final WMF image which includes all drawing commands
using (Aspose.Imaging.FileFormats.Emf.EmfImage emfImage = graphics.EndRecording())
{
emfImage.Save(dir + "test.output.emf");
}
DrawRectangle(Pen, rectangle)
Draai de rectangel.
public void DrawRectangle(Pen pen, Rectangle rectangle)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
rectangle
Rectangle
De rectangle om te trekken.
DrawString(String, Font, kleur, int en int)
Draai de string.
public void DrawString(string @string, Font font, Color color, int x, int y)
Parameters
string
string
De string.
font
Font
Schrift die het tekstformaat van de string definieert.
color
Color
De tekst kleur.
x
int
De x-koordinaat van de bovenste linker hoek van de getekende tekst.
y
int
De y-koordinaat van de bovenste linker hoek van de getekende tekst.
Examples
Dit voorbeeld laat zien hoe je een EMF-afbeelding van een bestand kunt laden en een tekstlijn over het kunt draaien.
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");
}
}
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van 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, kleur, int,int, float)
Draai de string.
public void DrawString(string @string, Font font, Color color, int x, int y, float angle)
Parameters
string
string
De string.
font
Font
Schrift die het tekstformaat van de string definieert.
color
Color
De tekst kleur.
x
int
De x-koordinaat van de bovenste linker hoek van de getekende tekst.
y
int
De y-koordinaat van de bovenste linker hoek van de getekende tekst.
angle
float
De hoek in graden, tussen de escape vector en de x-axis van het apparaat.De escape vector is parallel aan de baseline van een tekstlijn.
ExcludeClip(Rectangle)
Update het clipgebied van deze Grafik om het gebied dat door een Rectangle-structuur wordt aangegeven uit te sluiten.
public void ExcludeClip(Rectangle rect)
Parameters
rect
Rectangle
Rectangle structuur die de rectangel specificeert om uit de clipregio te uitsluiten.
ExcludeClip(Region)
Update het clipgebied van deze grafiek om het door een regio aangegeven gebied uit te sluiten.
public void ExcludeClip(Region region)
Parameters
region
Region
De regio die de regio specificeren om uit de clip-regio te worden uitgesloten.
FillEllipse(Brush en rectangle)
De ellipsie wordt gevuld.
public void FillEllipse(Brush brush, Rectangle rect)
Parameters
brush
Brush
Brush die de kenmerken van de vullen bepaalt.
rect
Rectangle
De grenzen van de ellipses.
FillPath(Pen, Brush en GraphicsPath)
Vullen de weg.
public void FillPath(Pen pen, Brush brush, GraphicsPath path)
Parameters
pen
Pen
Pen die de kleur, breedte en stijl van de figuur bepaalt.
brush
Brush
Brush die de kenmerken van de vullen bepaalt.
path
GraphicsPath
De weg om te vullen.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van 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(Brush, rectangle, float, float)
Vullen de pie.
public void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle)
Parameters
brush
Brush
Brush die de kenmerken van de vullen bepaalt.
rect
Rectangle
De grenzen van de ellipses.
startAngle
float
Winkel in graden gemeten klokwijze van de x-axis tot het uitgangspunt van de arc.
sweepAngle
float
Winkel in graden gemeten klokwijze van de startWinkel parameter tot het eindpunt van het arc.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van 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(Brush, punt[])
Vul de polygon op.
public void FillPolygon(Brush brush, Point[] points)
Parameters
brush
Brush
Brush die de kenmerken van de vullen bepaalt.
points
Point
[]
De punten .
FillPolygon(Brush, punt[], De FillMode)
Vul de polygon op.
public void FillPolygon(Brush brush, Point[] points, FillMode fillMode)
Parameters
brush
Brush
Brush die de kenmerken van de vullen bepaalt.
points
Point
[]
De punten .
fillMode
FillMode
De Fill Mode.
FillRectangle(Brush en rectangle)
De rectangle vullen.
public void FillRectangle(Brush brush, Rectangle rectangle)
Parameters
brush
Brush
Brush die de kenmerken van de vullen bepaalt.
rectangle
Rectangle
De rectangle om te vullen.
Examples
Dit voorbeeld laat zien hoe u een WMF-afbeelding kunt maken en geometrische vormen kunt tekenen met behulp van 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");
}
Dit voorbeeld laat zien hoe je een EMF-afbeelding kunt maken en er enkele geometrische vormen op kunt tekenen met behulp van 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()
De wereld verandert.
public Matrix GetTransform()
Returns
De transformatie matrix.
IntersectClip(RectangleF)
Update het clipgebied van deze Graphics naar de intersection van de huidige clipregio en de aangegeven Rectangle structuur.
public void IntersectClip(RectangleF rect)
Parameters
rect
RectangleF
Rectangle structuur om te intersect met de huidige clip regio.
IntersectClip(Region)
Update het clipgebied van deze Grafiek naar de kruising van de huidige clipregio en de aangegeven regio.
public void IntersectClip(Region region)
Parameters
region
Region
De regio om te kruipen met de huidige regio.
MultiplyTransform(Matrix)
Vermenigvuldigt de transformatie van deze grafiek in de wereld en bepaalt de matrix.
public void MultiplyTransform(Matrix matrix)
Parameters
matrix
Matrix
De matrix die de transformatie van de wereld vermenigvuldigt.
MultiplyTransform(Matrix en MatrixOrder)
Vermenigvuldigt de transformatie van deze grafiek en bepaalt de matrix in de aangegeven volgorde.
public void MultiplyTransform(Matrix matrix, MatrixOrder order)
Parameters
matrix
Matrix
De matrix die de transformatie van de wereld vermenigvuldigt.
order
MatrixOrder
De orde van de vermenigvuldiging.
ResetClip()
herstellen van de clip.
public void ResetClip()
RotateTransform(Vloot)
Gebruik de gespecificeerde rotatie aan de transformatiematrix van deze Graphics.
public void RotateTransform(float angle)
Parameters
angle
float
De hoek van rotatie in graden.
RotateTransform(Float, PointF en MatrixOrder)
Gebruik de gespecificeerde rotatie aan de transformatiematrix van deze Graphics in de aangegeven volgorde.
public void RotateTransform(float angle, PointF center, MatrixOrder order)
Parameters
angle
float
De hoek van rotatie in graden.
center
PointF
Het rotatingcentrum.
order
MatrixOrder
Bepaal of de rotatie wordt aangesloten of gepleegd aan de matrixtransformatie.
ScaleTransform(De vloot, de vloot)
De aangegeven schaaloperatie wordt toegepast op de transformatiematrix van deze Graphics door deze te voorschrijven op het transformatiematrix voor het object.
public void ScaleTransform(float sx, float sy)
Parameters
sx
float
Scalefactor in de richting x.
sy
float
Scale factor in de y richting.
ScaleTransform(vloat, vloat, matrixOrder)
De aangegeven schaaloperatie wordt toegepast op de transformatiematrix van deze Graphics in de gegeven volgorde.
public void ScaleTransform(float sx, float sy, MatrixOrder order)
Parameters
sx
float
Scalefactor in de richting x.
sy
float
Scale factor in de y richting.
order
MatrixOrder
Het bepaalt of de scaling-operatie wordt verplaatst of aangesloten aan de transformatiematrix.
SetTransform(Matrix)
Stel de transformatie op.
public void SetTransform(Matrix transform)
Parameters
transform
Matrix
De nieuwe transformatie matrix.
Examples
Dit voorbeeld laat zien hoe je een EMF-afbeelding van een bestand kunt laden en een tekstlijn over het kunt draaien.
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(De vloot, de vloot)
Verandert de oorsprong van het coördinatiesysteem door de gespecificeerde vertaling aan de transformatiematrix van deze Graphics te voegen.
public void TranslateTransform(float x, float y)
Parameters
x
float
De x-coördinatie van de vertaling.
y
float
De y-coördinatie van de vertaling.
TranslateTransform(vloat, vloat, matrixOrder)
Verandert de oorsprong van het coördinatiesysteem door de gespecificeerde vertaling toe te passen aan de transformatiematrix van deze Graphics in de aangegeven volgorde.
public void TranslateTransform(float x, float y, MatrixOrder order)
Parameters
x
float
De x-coördinatie van de vertaling.
y
float
De y-coördinatie van de vertaling.
order
MatrixOrder
Het bepaalt of de vertaling wordt gepleegd of aangesloten aan de transformatiematrix.