System.Drawing in dotnet6

The System.Drawing.Common is the actual implementation of the System.Drawing library. However, it is now attributed as a Windows-specific library in .NET 6 Framework. Therefore, you can use Aspose.Drawing to create a cross-platform .NET 6 Framework-based application. This article covers how to draw text or vector graphics using Brushes in non-Windows platforms like Linux, macOS with .NET 6 Framework.

Aspose.Drawing for .NET provides truly cross-platform support as it is written with fully managed code. You can easily access the API by downloading its DLL file from the Downloads section or from the NuGet gallery with the following installation command:

PM> Install-Package Aspose.Drawing

Using System.Drawing in .NET 6 on non-Windows Platform

Pre-requisites

  • .NET Framework 6.0
  • Microsoft Visual Studio 2022 (Latest Preview Version)

First of all, you need to download Microsoft Visual Studio 2022 Preview until the stable version is released. Installing Visual Studio 2022 Preview will also install .NET Framework 6.0 in a few minutes, based on your internet connection. Now we are good to proceed with further steps.

It is worth mentioning here that you can easily use System.Drawing in .NET 6 on the non-Windows environment like Linux, macOS, etc. However, you will find this demonstration using the macOS environment.

Create a C# Console Application

Once the Visual Studio installation is complete, you need to create a C# Console Application and proceed to install Aspose.Drawing from the NuGet gallery, as explained already.

Next, you can draw a gradient on an image with Bitmap and Brush classes. Simply copy-paste the following code in the Program.cs file of your project:

Output Drawing Preview

After running the code snippet above, an image containing the gradient like the following snapshot will be created on your end.

Get Free Temporary License

You can avoid the watermark and evaluation limitations by getting a free temporary license. This will enable you to test the API in its full capacity.

Conclusion

In this article, you have learned how to work with System.Drawing features in .NET 6 based application on non-windows platforms. You may like to visit the documentation section for further details about drawing text or processing drawings, etc. Furthermore, please feel free to discuss any of your concerns or inquiries with us via the forum.

See Also

Using System.Drawing with ASP.NET Core or ASP.NET Service