I have an image in a PictureBox and I want to be able to have buttons on my form that allow a user to zoom in and out as they wish. However, it doesn't seem like the .Zoom property works with the PictureBox. Is there another way around in this? Maybe a way to scale the PictureBox according to the same way .Zoom would work? Here's my code, but it did not zoom in or out:
Code:
Public Const ZOOM_MAX As Double = 25600
Public Const ZOOM_MIN As Double = 0.1
Private Sub mnuViewZoomIn_Click()
On Error GoTo ErrHandle
pic.Picture.Zoom = 2 * pic.Picture.Zoom
tbToolBar.Buttons("ZoomOut").Enabled = True
If pic.Picture.Zoom >= ZOOM_MAX Then
tbToolBar.Buttons("ZoomIn").Enabled = False
End If
Exit Sub
ErrHandle:
tbToolBar.Buttons("ZoomIn").Enabled = False
End Sub
Private Sub mnuViewZoomout_Click()
On Error GoTo ErrHandle
pic.Picture.Zoom = 0.5 * pic.Picture.Zoom
tbToolBar.Buttons("ZoomIn").Enabled = True
If pic.Picture.Zoom <= ZOOM_MIN Then
tbToolBar.Buttons("ZoomOut").Enabled = False
End If
Exit Sub
ErrHandle:
tbToolBar.Buttons("ZoomOut").Enabled = False
End Sub
HanneSThEGreaT, that is a very clever program. Thank you! I'm trying to adapt something like that in my program; however, I'm having trouble. I have one PictureBox containing an image like your Picture1, but I need that full image & PictureBox to zoom in or out rather than having a second PictureBox that shows the zoom (Picture3 in your program). I can move Mouse events into my Zoom Button click functions, but my problem is adapting to using only one PictureBox. Any guidance in the right direction is much appreciated.
Hmmm the picturebox control does not even have a zoom property..
Zoom applies only to the printers control's
Originally Posted by VB Books Online
Applies To
Printer Object, Printers Collection
Returns or sets the percentage by which printed output is to be scaled up or down. Not available at design time.
Syntax
object.Zoom [= number]
Hannes, that is smart code.
Slowcoder, to finally solve the problem we need to look at posibly passing the image in a hidden picturebox to StretchBlt... Hmm where's Dan when you need him ???
Thanx guys, you made my day!
I'll second the idea of making use of g hidden picturebox.
I'm busy with another option, slowcoder, I'll post it tomorrow.
WOW! HanneSThEGreaT & GremlinSA...your projects are great! And Gremlin, that scrollbar is a perfect addition to the zoom feature I'm going to try and adapt these concepts into my project today; however, I noticed that there's an Image control used....and I think I goofed in my earlier post by not saying that my image is actually a picture bound to the picturebox: pictureBox1.Picture = LoadPicture(TempFileName)
I definitely need to be more careful with my terminology. So I'm going to try and change my project to use an image control instead, but we'll see if I break any other code in the process...
WOW! HanneSThEGreaT & GremlinSA...your projects are great! And Gremlin, that scrollbar is a perfect addition to the zoom feature I'm going to try and adapt these concepts into my project today; however, I noticed that there's an Image control used....and I think I goofed in my earlier post by not saying that my image is actually a picture bound to the picturebox: pictureBox1.Picture = LoadPicture(TempFileName)
I definitely need to be more careful with my terminology. So I'm going to try and change my project to use an image control instead, but we'll see if I break any other code in the process...
Are you trying to add this to the crop image app we worked on before..
I had an idea about it...
using a Rouge hidden Imagebox... leave the picturbox in place.. when doing a zoom, put the pic in the Imagebox. Zoom it to the right size. Place it over the Picbox in the right possition. Make it visible. BitBlt it into the Picture box, then hide it again..
Look it's going to be alot of code, and right now the wife want a bit of time online, so i wont be able to look at it right now.. but i will look into doing something a bit later..
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.