Zoom in Picturebox

FreewareFire

Active member
Joined
May 23, 2003
Messages
28
Hi,

how do i create a zoom function for a picturebox? The Problem is, i didnt load a image before! I draw something on it like paint does. After i painted what i want, i want to zoom it! But i get an error that no image is loaded... Could someone help :confused: Thx! - i need to use PictureBox, so dont tell me to use Graphics...

Thx

FreewareFire


sorry, i forgot - i use C#...
 
Did you set the Image property of the picturebox?

For your zoom question, you will have to create a new Bitmap and make it the same size as the picturebox.
Bitmap b=new Bitmap(picture box size);

Then you will have to create a graphics object from b.
Graphics g= Graphics.FromImage(b);

Then using draw Image draw only the selected part to the image that is zoomed making it the same size as the picturebox.
g.DrawImage(you figure this out - too complicated to just write it here off top of head);

Then
picturebox1.Image= b;
 
this is a weird suggestion but,

try doing this, set the image state to the picturebox to "strectch"
and have an "enlarged" image of the image that your gonna zoom, and just change the picture to that image...

...

anyway, if this sounds stupid just listen to what AEWarNick said
i dunno thats how i used to do it
 
I never use picture boxes, so I had forgotten about the stretch property. So it may be easiest to do it that way, although, when you use the DrawImge funciton you need to set a size anyway. You might as well make it the size of the picturebox and forget about setting the stretch property because it will already be the size you want.
 
Back
Top