downsize bitmap c# code example
Example: 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;
}