Draw Shapes in C#

It is often required to create different graphical objects by drawing shapes including circles, lines, rectangles, etc. These shapes could also be used for the annotation of the images. In this article, you will learn how to draw different shapes programmatically in C#. We will demonstrate how to draw lines, ellipses, arcs, and rectangles and generate their images.

C# API to Draw Shapes - Free Download

To draw different types of shapes, we will use Aspose.Imaging for .NET. It is an amazing image editing API that provides a wide range of features to manipulate images and create drawings. You can either download the API or install it from NuGet.

PM> Install-Package Aspose.Imaging

Draw a Line using C#

The following are the steps to draw a line in C#.

The following code sample shows how to draw a line in C#.

The following is the output of the above code sample.

draw line in C#

Draw an Ellipse using C#

The following are the steps to draw an ellipse in C#.

The following code sample shows how to draw an ellipse on an image in C#.

The following is the output of the above code sample.

draw ellipse in C#

Draw an Arc using C#

The following are the steps to draw an arc in C#.

The following code sample shows how to draw an arc on an image in C#.

The following is the output of the above code sample.

draw arc in C#

Draw an Rectangle using C#

The following are the steps to draw a rectangle in C#.

The following code sample shows how to draw a rectangle on an image in C#.

The following is the output of the above code sample.

draw rectangle in C#

C# .NET Image Drawing API - Get a Free License

You can get a free temporary license and draw shapes without evaluation limitations.

Conclusion

In this article, you have learned how to draw shapes in C#. We have covered how to draw lines, ellipses, arcs, and rectangles on images programmatically. You can easily integrate the provided code samples into your C# applications.

Read More

You can explore more about the .NET image processing API using documentation. Also, you can share your queries with us via our forum.

See Also