This was a bit more involved than I expected due to SizeMode (Normal, Center, Stretch), scrolling, borders, etc. but I think I've got it working now. I did end up using the Graphics.FromImage method as part of the solution. Thanks for the jump start
----- Alex Yakhnin [MVP] wrote: ----
Something like this (untested - don't have VS at my hands at the moment)
public Bitmap ResizeImage(Image image, Rectangle newSize
Bitmap tempBmp = new Bitmap(newSize.Width, newSize.Height)
//create temp Graphic
Graphics gx = Graphics.FromImage(tempBmp)
//resize imag
gx.DrawImage(image, newSize, new Rectangle(0, 0, image.Width, image.Height)
return tempBitmap
-
Alex Yakhnin, .NET CF MV
----- Dan French wrote: ----
Does anyone know how to resize an image in a PictureBox? I have been able to resize an image using Graphics.DrawImage in OnPaint, but CF does not support the CreateGraphics method for a PictureBox. I can select SizeMode in a PictureBox and that handles the different mode requirements that I have, but CF does not support SizeMode for anything but a PictureBox. If I could get the image associated with the Graphics object after I draw it and then pass that to the PictureBox, that would suffice, but I can't seem to find how to do that either. Any ideas will be appreciated