Padding Images using GDI+
September 9, 2009 at 3:07 PM
—
Alec Bryte
Recently I had to poke around in the good ol’ WinForms code and add some spacing to the images posted onto a form. I wrote a simple helper method for adding that extra space (padding) around the image. Here it is:
public static Image PadImage(Image source, int left, int top, int right, int bottom)
{
Bitmap bmp = new Bitmap(source.Width + left + right, source.Height + top + bottom);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(source, left, top);
g.Dispose();
return bmp;
}
690209c0-f7b8-4890-85d0-304de2370c25|1|5.0
Posted in: .NET | WinForms
Tags: