Answers for "c# resize bitmap"

C#
3

c# resize bitmap

//Size of "testimage.bmp" file is 1024x1024.
Bitmap bmp = (Bitmap)Bitmap.FromFile(@"C:\testimage.bmp");
Bitmap newImage = ResizeBitmap(bmp, 512, 512);

public Bitmap ResizeBitmap(Bitmap bmp, int width, int height)
{
    Bitmap result = new Bitmap(width, height);
    using (Graphics g = Graphics.FromImage(result))
    {
        g.DrawImage(bmp, 0, 0, width, height);
    }
 
    return result;
}
Posted by: Guest on March-18-2020

C# Answers by Framework

Browse Popular Code Answers by Language