使用picturebox显示图片,但是由于图片过大,如果autosize 设置成TRUE的话,会超出屏幕显示范围
有没有什么办法能让图片缩小为合适的大小,能在屏幕范围内完全显示。
如果不能用picturebox实现,可有什么其他的控件可以做到图片的缩放吗?谢谢指教!
有没有什么办法能让图片缩小为合适的大小,能在屏幕范围内完全显示。
如果不能用picturebox实现,可有什么其他的控件可以做到图片的缩放吗?谢谢指教!
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long'在Form上放一个picture box,并事先定义好一个图片,增加一个按钮
'例2: 放大或缩小图片
'放大:
Private Sub Command1_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Picture1.hdc, 0, 0, w * 2, h * 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'缩小:
Private Sub Command2_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, 0, 0, w / 2, h / 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'例3: 翻转图片
'左右翻转
Private Sub Command3_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, w, 0, -w, h, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'上下翻转
Private Sub Command4_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, 0, 0, w / 2, h / 2, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
'左右并且上下翻转
Private Sub Command5_Click()
Dim w As Integer, h As Integer
Me.ScaleMode = vbPixels
w = Picture1.Width
h = Picture1.Height
StretchBlt Me.hdc, w, h, -w, -h, Picture1.hdc, 0, 0, w, h, vbSrcCopy
End Sub
set picP = loadpicture(....)picture1.paintpicture picp,0,0,picture1.width,picture1.height
需先加上一句:SetStretchBltMode hdc, 4
不然图片效果会惨不忍睹的!