我有一张很大的图片,如何用vb实现图片的移动和缩放功能?
因为图片太大,如果装入image控件怎样实现图片的长宽等比例缩放,并且实现图片的放大缩小和移动的功能,并且image控件在窗体最大化和还原状态总是充满窗口 --------------------编程问答-------------------- 用這個控件http://www.gdpicture.com/ --------------------编程问答-------------------- 建议你使用GDI+来处理,很容易 --------------------编程问答-------------------- Private Sub PaintPhoto(xPic As IPictureDisp, Optional TxForm As Object = Nothing)
Dim r As Double, RP As Double
Dim W As Long, H As Long
Dim x As Long, y As Long
Dim X1 As Long, Y1 As Long
Dim X0 As Long, Y0 As Long
If xPic Is Nothing Then Exit Sub
x = xPic.Width
y = xPic.Height
If TxForm Is Nothing Then
X1 = Width
Y1 = Height
Else
X1 = TxForm.Width
Y1 = TxForm.Height
End If
r = y / x
RP = Y1 / X1
If r > RP Then
H = Y1 ' picPhoto.Height
W = H / r
Y0 = 0
X0 = (X1 - W) / 2
Else
W = X1 'picPhoto.Width '- picPhoto.ScaleWidth
H = W * r
X0 = 0
Y0 = (Y1 - H) / 2
End If
If Not TxForm Is Nothing Then
TxForm.Picture = Nothing
TxForm.PaintPicture xPic, X0, Y0, W, H ', 0, 0, X, Y
End If
End Sub --------------------编程问答-------------------- TxForm 可以是任意的Form,pictureBox,用户控件。。。
补充:VB , VBA