Hi,
I created some thumbnails from pictures - they all have a size of up to
80 pixels in width or height (if it is a square pic, the size is
exactly 80 x 80, otherwise 80 pixel is the size of the greater
dimension).
For displaying purposes, I want to view them all in the same size, that
is 80 x 80.
Pictures that are smaller shall have a white border to fill up the size
to 80 pixels.
How can I do that? I have the thumbnail already in a
System.Drawing.Image object, but I have no clue how to add this white
border, or even how to create the empty 80 x 80 white picture first,
where I want to draw my thumbnail into. I looked already for the
classes Bitmap, DrawImage, Graphics (all in namespace System.Drawing),
but couldn't find any appropriate method.
I appreciate any help,
TheLetti
Markus Stoeger - 04 Aug 2005 00:35 GMT
> How can I do that? I have the thumbnail already in a
> System.Drawing.Image object, but I have no clue how to add this white
> border, or even how to create the empty 80 x 80 white picture first,
> where I want to draw my thumbnail into. I looked already for the
> classes Bitmap, DrawImage, Graphics (all in namespace System.Drawing),
> but couldn't find any appropriate method.
Try that...
// create a new bitmap
Bitmap bmp = new Bitmap(200, 200);
// get a Graphics object for drawing on the bitmap
Graphics g = Graphics.FromImage(bmp);
// draw on it
g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);
g.FillEllipse(Brushes.Red, 0, 0, bmp.Width, bmp.Height);
// save it, or put it in a picturebox,...
bmp.Save(@"C:\MyImage.bmp", ImageFormat.Bmp);
TheLetti - 04 Aug 2005 09:48 GMT
Hello Markus,
thank you very much for your input. I figured it out right now thanks
to your help.
greez,
TheLetti