Add border to PNG image file via C#
Enhance PNG Images with Borders Using .NET Drawing API
Download Free TrialHow to Add Border to PNG Image File Using C#
Transform your PNG images with ease by adding borders using Aspose.Drawing for .NET API. This cross-platform 2D graphic library offers powerful tools to seamlessly integrate borders into your images. With the Aspose.Drawing API, you can effortlessly draw borders around your PNG images using C#. Utilize the Bitmap class and raster graphics drawing capabilities to achieve professional-quality results. Whether you're rendering raster images or saving PNG files, the Drawing API provides the flexibility and functionality you need to enhance your visuals. Experience the convenience of adding borders to PNG images with .NET's API and elevate your image editing process today. Open NuGet package manager, and search for Aspose.Drawing and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Drawing
Steps to Add border to PNG image via C#
You need the aspose.drawing.dll to try the following workflow in your own environment.
- Create bitmap object from PNG image file using
Bitmap
class. - Create graphics object using
Graphics.FromImage()
method. - Draw border with
DrawRectangle()
method. - Save created bitmap in PNG image format.
System Requirements
Aspose.Drawing for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Windows Application, ASP.NET Web Application.
- Development environment like Microsoft Visual Studio.
- Aspose.Drawing for .NET referenced in your project.
Add border to PNG Image File - C#
using Aspose.Drawing; | |
using (Bitmap bitmap = new Bitmap("cat.png")) | |
{ | |
Graphics graphics = Graphics.FromImage(bitmap); | |
graphics.DrawRectangle(new Pen(Color.Red, 10), new Rectangle(0, 0, bitmap.Width, bitmap.Height)); | |
bitmap.Save("out.png"); | |
} |
About Aspose.Drawing for .NET API
Aspose.Drawing, a fully managed, cross-platform 2D graphic library, excels in drawing text, geometries, and images. It offers a System.Drawing compatible API, effortlessly transforming your existing code that relies on System.Drawing into a truly cross-platform solution. Developed against .NET Standard 2.0, Aspose.Drawing finds application in web, mobile, desktop, cloud, and IoT scenarios.
The drawing engine within Aspose.Drawing empowers users to render vector graphics, including lines, curves, and figures, alongside diverse text elements in various fonts, sizes, and styles. This rendering process occurs seamlessly on raster images, supporting a wide array of commonly used graphics file formats.
Process PNG via Free Online App
Create PNG images, as well as add text to images by visiting our Live Demos website The live demo has the following benefits:
PNG What is PNG File Format
Files having extension .PNG represent Bitmap Image files that are used to store bitmap digital images. These images format serves the purpose of opening the file on multiple platforms such as Microsoft Windows, Mac and Linux. The PNG file format can store data as two-dimensional digital images in both monochrome as well as color format with various color depths.
Read More