C# Resize A Bitmap Example
This example shows how to resize a bitmap file in C#. To resize a bitmap image, we use Graphics class in System.Drawing namespace.
Usage:
//Size of "testimage.bmp" file is 1024x1024. Bitmap bmp = (Bitmap)Bitmap.FromFile(@"C:\testimage.bmp"); Bitmap newImage = ResizeBitmap(bmp, 512, 512);
Resize Method Example:
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; }
It WORKS, thank you!!!
Thank you there!
Your code give a piece of my solution, butwas very important.
Success for you!
P.S.: I´m from Brazil.