|
|
C# Imaging Library
How to draw, print path, graphs on image in C#?
Detailed guide to draw freehand, line, rectangle, polygon, arc graphs on the image in C# application.
RasteEdge XImage.Raster is a C# image reading, writing, converting, and processing library. You can easily print one image on another in the
C# ASP.NET Core, Framework, MVC, WinForms, and WPF applications.
You can quickly draw the following shapes and graphs on the image using XImage.Raster C# image library.
- Arc
- Bezier
- Circle
- Ellipse
- Freehand
- Line
- Polygon
- Polygon Line
- Rectangle
Draw Arc on image in C#
Arc shape is a curved line that is part of a circle, like a "bow" or a part of a round edge.
Here we will show how to draw a arc graph on an empty image in C#.
RasterImage image = new RasterImage(100, 100, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.Blue;
DrawMethod.DrawArc(image, 20, 10, 80, 50, 45, 270, info);
image.Save("C://output//raster-image-drawing-graph-arc.png");
Draw Bezier on image in C#
A Bezier shape or Bezier curves is a smooth, mathematically defined vector shape. It's not a single fixed form, but a flexible structure controlled by a set of control points.
Here we will show how to paint a Bezier graph on an empty image in C#.
RasterImage image = new RasterImage(100, 100, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.Blue;
List<Point> potins = new List<Point>(); potins.Add(new Point(40, 10));
potins.Add(new Point(20, 50));
potins.Add(new Point(90, 10));
potins.Add(new Point(70, 40)); DrawMethod.DrawBezier(image, potins, info);
image.Save("C://output//raster-image-drawing-graph-bezier.png");
Draw Circle on image in C#
A circle is a perfectly round, closed 2d shape.
Here we will explain how to print a circle graph on an empty image in C#.
RasterImage image = new RasterImage(200, 200, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.Blue;
Point center = new Point(100, 100);
Point anyPointOnCirle = new Point(100, 50);
DrawMethod.DrawCircle(image, center, anyPointOnCirle, info);
image.Save("C://output//raster-image-drawing-graph-circle.png");
Draw Ellipse on image in C#
An ellipse is a smooth, closed, oval shape.
Here we will explain how to print a ellipse graph on an empty image in C#.
RasterImage image = new RasterImage(200, 200, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.Blue;
DrawMethod.DrawEllipse(image, 100, 100, 60, 30, 0, 360, info);
image.Save("C://output//raster-image-drawing-graph-ellipse.png");
Draw FreeHand on image in C#
Freehand is a shape you draw freely by hand, without using rules like circles, straight lines, or perfect curves.
Here we will explain how to print a freehand shape on an empty image in C#.
RasterImage image = new RasterImage(500, 500, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.Blue;
Random random = new Random();
List<Point> points = new List<Point>();
for (int i = 0; i < 100; i = i + 5)
{
points.Add(new Point(random.Next(100, 500), random.Next(100, 500)));
}
DrawMethod.DrawFreeHand(image, points, info);
image.Save("C://output//raster-image-drawing-graph-freehand.png");
Draw Line on image in C#
A line shape is a straight path between two points.
Here we will explain how to print a line shape on an empty image in C#.
RasterImage image = new RasterImage(200, 200, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 4;
DrawMethod.DrawLine(image, 0, 0, 100, 100, info);
image.Save("C://output//raster-image-drawing-graph-line.png");
Draw Polygon on image in C#
A polygon is a 2D closed shape made of straight lines only, with no curves.
Here we will explain how to print a polygon shape on an empty image in C#.
RasterImage image = new RasterImage(500, 500, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.Blue;
Random random = new Random();
List<Point> points = new List<Point>();
for (int i = 0; i < 100; i = i + 5)
{
points.Add(new Point(random.Next(100, 500), random.Next(100, 500)));
}
DrawMethod.DrawPolygon(image, points, info);
image.Save("C://output//raster-image-drawing-graph-polygon.png");
Draw Polygon Line on image in C#
Polygon Line shape (also known ad polyline) is a shape made of connected straight lines, but not closed.
Here we will explain how to print a polyline shape on an empty image in C#.
RasterImage image = new RasterImage(500, 500, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.FromArgb(0,0,0,0);
Random random = new Random();
List<Point> points = new List<Point>();
for (int i = 0; i < 100; i = i + 5)
{
points.Add(new Point(random.Next(100, 500), random.Next(100, 500)));
}
DrawMethod.DrawPolygonLine(image, points, info);
image.Save("C://output//raster-image-drawing-graph-polygon-line.png");
Draw Rectangle on image in C#
A rectangle is a 4-sided polygon with the following rules:
- 4 straight sides
- 4 right angles
- opposite sides are equal and parallel
Here we will explain how to print a rectangle shape on an empty image in C#.
RasterImage image = new RasterImage(200, 200, Color.White);
DrawingInfo info = new DrawingInfo();
info.OutLineColor = Color.Red;
info.OutlineWidth = 2;
info.FillColor = Color.FromArgb(0,0,0,0);
DrawMethod.DrawRectangle(image, new Rectangle(75, 50, 50, 100), info);
image.Save("C://output//raster-image-drawing-graph-rectangle.png");
|