用vb怎样做一个图片放大器?

用vb怎样做一个图片放大器?,第1张

放大纤并镜的实现(其他自己族晌写吧,不是什么难题):

Pic1存放源图,Pic2 存放放大后的图片(即放大镜)。这里是放大两倍,Pic2大小固定,被放大的源图是Pic2一兆竖锋半大小,以鼠标当前位置为中心的一个矩形。

将 pic2 放到 pic1里(即在 pic1 里面画 pic2),设置pic2.Enable=false

添加以下事件:

Private Sub Pic1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Pic2.PaintPicture Pic1.Picture, 0, 0, Pic2.Width, Pic2.Height, X - Pic2.Width / 4, Y - Pic2.Height / 4, Pic2.Width / 2, Pic2.Height / 2

Pic2.Move X - Pic2.Width / 2, Y - Pic2.Height / 2

End Sub

Option Explicit

Private Type POINTAPI

x As Long

y As Long

End Type

Const Srccopy = &HCC0020

Private Declare Function GetCursorPos Lib "User32" (lpPOINT As POINTAPI) As Long

Private Declare Function GetDC Lib "User32" (ByVal hWnd As Long) As Long

Dim pos As POINTAPI

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 Sub Form_Load()

Dim usew&, useh&

usew&= Me.Width / Screen.TwipsPerPixelX

useh&= Me.Height / Screen.TwipsPerPixelY

End Sub

Private Sub Start()

Dim sx As Long

Dim sy As Long

GetCursorPos pos

Dim x, y

sx = IIf(pos.x <50 Or pos.x >925, IIf(pos.x <50, 0, 925), pos.x - 50)

sy = IIf(pos.y <50 Or pos.y >680, IIf(pos.y <50, 0, 680), pos.y - 50)

Caption = " 坐标喊腔"笑源 &sx &"," &sy &" 放大镜碰渗态”"

StretchBlt hdc, 0, 0, 200, 200, GetDC(0), sx, sy, 100, 100, Srccopy '改动

End Sub

Private Sub Timer1_Timer()

Start

End Sub

Private Sub Form_DblClick()

Unload Me

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12517143.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2025-08-25
下一篇2025-08-25

发表评论

登录后才能评论

评论列表(0条)

    保存