picturebox中图片放大缩小问题
在picture1中,用鼠标mousedown时有(x1,y1),mouseup时(x2,y2),怎么把鼠标圈住的里面的内容放大到整个picturebox中去?
问题点数:50、回复次数:10Top
1 楼TechnoFantasy((VB MVP)www.applevb.com)回复于 2003-12-03 16:54:04 得分 25
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 SRCCOPY = &HCC0020 ' (DWORD) dest = source
Dim x1 As Long
Dim y1 As Long
Dim x2 As Long
Dim y2 As Long
Private Sub Form_Load()
Picture1.ScaleMode = 3
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = CLng(X)
y1 = CLng(Y)
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
x2 = CLng(X)
y2 = CLng(Y)
StretchBlt Picture1.hdc, 0, 0, Picture1.Width / 15, Picture1.Height / 15, Picture1.hdc, x1, y1, x2 - x1, y2 - y1, SRCCOPY
End Sub
Top
2 楼scorpions215(asdf)回复于 2003-12-04 08:35:10 得分 0
一定要scalemodel=3么?我scalemodel=0行不行的
我是用scalemodel画出来的图,想把它放大的Top
3 楼szyhy810518()()回复于 2003-12-04 08:58:27 得分 0
StretchBlt Picture1.hdc, 0, 0, Picture1.Width / 15, Picture1.Height / 15, Picture1.hdc, x1, y1, x2 - x1, y2 - y1, SRCCOPY
我要是得到这个函数的返回值好像就不会正确执行?Top
4 楼szyhy810518()()回复于 2003-12-04 08:59:34 得分 0
是跟踪调试的时候不会正确执行Top
5 楼scorpions215(asdf)回复于 2003-12-04 09:03:39 得分 0
for i=1 to 10
picture1.line(m(i,1),m(i,2))-m(i-1,1)m(i-1,2)
next
的时候
要这线在(x1,y1),(x2,y2)
范围内画出来,超出范围的不画,怎么做?Top
6 楼szyhy810518()()回复于 2003-12-04 09:18:42 得分 25
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
x1 = CLng(X)
y1 = CLng(Y)
blnMove = True
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'应该是在(x1,y1),(x,y)范围内吧!
If blnMove Then
With Line1(0)
.x1 = x1
.y1 = y1
.x2 = x1
.y2 = Y
End With
With Line1(1)
.x1 = x1
.y1 = y1
.x2 = X
.y2 = y1
End With
With Line1(2)
.x1 = X
.y1 = y1
.x2 = X
.y2 = Y
End With
With Line1(3)
.x1 = x1
.y1 = Y
.x2 = X
.y2 = Y
End With
End If
Label1.Caption = X & Space(10) & Y
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim iIndex As Integer
Dim lngResult As Long
x2 = CLng(X)
y2 = CLng(Y)
'StretchBlt Picture1.hdc, 0, 0, Picture1.Width / 15, Picture1.Height / 15, Picture1.hdc, x1, y1, x2 - x1, y2 - y1, SRCCOPY
lngResult = StretchBlt(Picture1.hdc, 0, 0, Picture1.Width / 15, Picture1.Height / 15, Picture1.hdc, x1, y1, x2 - x1, y2 - y1, SRCCOPY)
If lngResult = 0 Then
MsgBox "FDf"
End If
For iIndex = 0 To 3
With Line1(iIndex)
.x1 = 0
.y1 = 0
.x2 = 0
.y2 = 0
End With
Next
blnMove = False
Picture1.Refresh
End Sub
Top
7 楼szyhy810518()()回复于 2003-12-04 09:28:20 得分 0
如何获得图片已经扩大到不能再扩大,即使整个picture1都显示一种颜色?Top
8 楼scorpions215(asdf)回复于 2003-12-04 09:39:46 得分 0
比如我picture1.scale(0,0)-(1000,1000)的时候
for i=1 to 10
picture1.line(m(i,1),m(i,2))-m(i-1,1)m(i-1,2)
next
的时候
要这线在(100,100),(800,800)
范围内画出来,可能有线(700,700)-(900,900)
我要在范围内的显示,超出的不显示 用你刚才的方法可以么?
Top
9 楼scorpions215(asdf)回复于 2003-12-04 09:41:15 得分 0
我刚才说的图片不要放大了,就在范围内画线Top
10 楼scorpions215(asdf)回复于 2003-12-04 09:45:45 得分 0
是不是用pset的方法可以?还有没有别的方法Top




