Hi @Saranya Karthik , Welcome to Microsoft Q&A,
You may consider using the System.Drawing namespace in .NET Framework or .NET Core.
System.Drawing provides a set of classes and methods for processing images that can be used to achieve your target effects.
Here is sample code implemented using System.Drawing to convert a PNG image to a BMP image and set the DPI:
using System.Drawing;
using System.Drawing.Imaging;
string inputFilePath = "input.png";
string outputFilePath = "output.bmp";
using (Bitmap pngBitmap = new Bitmap(inputFilePath))
{
// Create a new Bitmap with the same dimensions as the original PNG bitmap
Bitmap bmpBitmap = new Bitmap(pngBitmap.Width, pngBitmap.Height);
// Copy the PNG bitmap to the BMP bitmap
using (Graphics graphics = Graphics.FromImage(bmpBitmap))
{
graphics.DrawImage(pngBitmap, 0, 0);
}
// Set the DPI for the BMP bitmap
bmpBitmap.SetResolution(300, 300);
// Save the BMP bitmap to a file
bmpBitmap.Save(outputFilePath, ImageFormat.Bmp);
}
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.