Click to See Complete Forum and Search --> : How to implement zooming capabilities on graphics?


diarra2789
September 11th, 1999, 06:57 PM
I am creating an image viewer, and I would like to know how to implement zooming capability on a graphic displayed in a picture box: eg: 25%,50% 100%, 110% etc. (25% being the smallest and 100% being the actual size (No strech)). Also, if the actual size of the picture is greater than its container when it is loaded, the vertical and horizontal bar should appear automatically!

Thanks

February 5th, 2000, 02:46 AM
option Explicit 'Just to let you know where we are...
Dim intSize as Integer

'Put this code in the event you want to zoom away on:
'Zooming in...
intSize = intSize + 1
If intSize < 0 then
if intSize = -1 then
intSize = -2
end if
Dim picPic as Picture
set picPic = picPictureBox.Picture
picPictureBox.Picture = LoadPicture()
picPictureBox.PaintPicture(picPic, 0, 0, (-1) * picPictureBox.Width / intSize, (-1) * picPictureBox.Height / intSize)
'This should handle the zooming in...
else
if intSize = 0 then
intSize = 1
end if
Dim picP as Picture
set picP = picPictureBox.Picture
picpicturebox.Picture = LoadPicture()
picPictureBox.PaintPicture(picP, 0, 0, intSize * picPictureBox.Width, intSize * picPictureBox.Height)
end if





There you go, enjoy.