Why, with extension methods, of course:
public static class ExtendBitmap
{
public static Bitmap Resize(this Bitmap bmp, int nWidth, int nHeight )
{
Bitmap result = new Bitmap(nWidth, nHeight);
using(Graphics g = Graphics.FromImage((Image)result))
{
g.DrawImage(bmp, 0, 0, nWidth, nHeight);
}
return result;
}
public static Bitmap Resize(this Bitmap bmp, double percent)
{
int width = (int)(bmp.Width * (percent*0.01));
int height = (int)(bmp.Height * (percent*0.01));
Bitmap result = bmp.Resize(width, height);
return result;
}
}
Load the bitmapo the way you normally would, and then do this:
Bitmap bmp = Bitmap.FromFile("blah blah");
bmp = bmp.Resize(50);
bmp = bmp.Resize(320, 240);