|
-
May 5th, 2005, 01:52 PM
#1
Thread Starter
New Member
Zoom on Picture
Is there any way in vb that when I scroll over a picture box or click on a picure box, that it would 'blow up' to a bigger image and go back to the original size once you scroll off of the picture or reclick ?
-
May 5th, 2005, 01:59 PM
#2
Re: Zoom on Picture
StretchBlt is what you want:
VB Code:
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest
Private Const SRCPAINT = &HEE0086 ' (DWORD) dest = source OR dest
Function StretchPic(picBox As PictureBox, times As Integer) As Long
StretchBlt picBox.hdc, 0, 0, picBox.ScaleWidth * times, picBox.ScaleHeight * times, picBox.hdc, 0, 0, picBox.ScaleWidth, picBox.ScaleHeight, SRCCOPY
End Function
Use it like this:
VB Code:
StretchPic PictureBox, 2 '2 for 2 times the size..
Hope that helps 
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
May 5th, 2005, 02:44 PM
#3
Re: Zoom on Picture
Hi vbzoom and welcome to VBF!
Here is a small procedure that allows to zoom in/out image but KIM that the higher the resolution the more distorted it would get:
VB Code:
Public Sub ZoomPicture(pct As PictureBox, zoom As Double)
With pct
.Width = .Width * zoom
.Height = .Height * zoom
.PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight
End With
End Sub
'usage:
Private Sub Command1_Click()
'============================
'zoom it out
ZoomPicture Picture1, 0.9
End Sub
Private Sub Command2_Click()
'============================
'zoom it in
ZoomPicture Picture1, 1.1
End Sub
-
May 5th, 2005, 02:54 PM
#4
Thread Starter
New Member
Re: Zoom on Picture
Alright thanks....you guys helped out a lot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|