Cross platform 2D graphics library
Cross-platform graphics library for 2D drawing pictures for .NET
Drawing libraries for Microsoft .NET are widely utilized for creating 2D drawing applications and services. Developing a C# (C sharp) application for image drawing that can run on multiple platforms enables you to reach a broader customer base with minimal effort. Aspose.Drawing is a cross-platform solution for .NET that supports the most popular platforms and consistently delivers excellent quality results.
Aspose.Drawing supported platforms
Graphic libraries for .NET are not limited to the Windows platforms; they are also widely popular on other systems such as MacOS, Linux, Android, Azure Functions, ASP.NET WebApp and Blazor WebAssembly. One major advantage of Aspose.Drawing.Common API is its cross-platform compatibility, allowing you to utilize it simultaneously on multiple platforms. Developing with a single library streamlines the application creation process. You can reuse code developed once across multiple platforms. Aspose.Drawing is compatible with all target platforms listed in the Supported frameworks list, making it suitable for any choice you make.
How to install Aspose.Drawing for different platforms
If you are developing within the Visual Studio development environment, you can easily install Aspose.Drawing using the integrated NuGet package manager. Simply search for `Aspose`, select `Aspose.Drawing` or `Aspose.Drawing.Common`, and click Install. Alternatively, you can install Aspose.Drawing from the NuGet package manager command line by typing the following command:
> Install-Package Aspose.Drawing
For more detailed installation instructions please visit the Aspose.Drawing Installation Guide.
Aspose.Drawing can serve as a graphic library for various target platforms, including Windows, MacOS, Linux, Azure, ASP sites, and Blazor WebAssembly applications. In Visual Studio, you have the flexibility to create new projects and run C# programs on .NET as Console Applications on Windows, Linux, or MacOS, as Web applications using ASP.NET Core or Blazor WebAssembly. Additionally, you can utilize the same Aspose drawing library for .NET MAUI applications on mobile platforms like Android or iOS.
To run a .NET application on Linux, you simply need to have .NET installed and ensure that `Aspose.Drawing.dll` is available in your project folder. You can download the binaries from the official Aspose website. Alternatively, you can define the API using the command line command:
> dotnet add package Aspose.Drawing
Furthermore, you can run C# applications with the Aspose library in a Docker container. For more information about Docker installation, please refer to the Aspose.Drawing documentation.
Aspose Drawing library use cases
Text on image
One of the most popular use case for 2D drawing is adding text to images, such as creating text on images for making gift cards. In the example below, we will draw a text string "Happy Birthday!" on the available space at the bottom right corner of the existing image. We will use the `SolidBrush` tool to draw the text string. You should choose the desired text color and a font with the appropriate size and style. Next, calculate the position of the `Rectangle` structure to fit the text, and then draw the text string using the `DrawString` method.
Example of C# code to draw text on an image:
Moreover, you can enhance the visual appeal by creating a color frame around images or photographs. This can be easily accomplished by choosing a `Pen` tool with your desired color and using the `DrawRectangle` method to draw the frame with the calculated width and height.
Example of C# code to draw a color frame around a photo:
Another useful scenario involves creating callouts on images to add supplementary information, such as diameter size details in mm. Callouts consist of several graphics primitives, and to draw them, we need to utilize various drawing methods such as `DrawLine`, `DrawEllipse`, and `DrawString`.
Example of C# code to draw callouts on an image:
Aspose.Drawing graphics library runs on a wide range of different platforms and relies solely on its own rendering functions, eliminating the need to install any other 3rd party components. To find more examples please visit the Aspose GitHub repository.