请大家帮忙看看 图像局部放大的程序,为什么结果不对呢,该怎么解决
请大家帮忙看看 图像局部放大的程序,为什么结果不对呢
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
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
Dim exp_x0, exp_y0, k, flag
Sub Form_Load()
disppic.AutoRedraw = True
disppic.AutoSize = True
disppic.Picture = LoadPicture( "C:\Documents and Settings\temp.bmp ")
disppic.ScaleMode = 3 - pixel
backpic.AutoRedraw = True
backpic.AutoSize = True
backpic.Picture = LoadPicture( "C:\temp.bmp ")
backpic.ScaleMode = 3 - pixel
backpic.Visible = False
End Sub
'当鼠标按下时:
Private Sub disppic_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
flag = 1
exp_x0 = x
exp_y0 = y
disppic.DrawStyle = 4 '(图象框disppic的绘图模式设置为虚线)
End Sub
'当鼠标拖动时:
Private Sub disppic_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If flag = 1 Then
k = BitBlt(disppic.hdc, 0, 0, disppic.Width, disppic.Height, backpic.hdc, 0, 0, &HCC0020)
'(把前一次的虚线框擦掉)
disppic.Line (exp_x0, exp_y0)-(x, y), RGB(0, 0, 0), B '(化虚线框)
End If
End Sub
'当鼠标被放开时:
Private Sub disppic_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
flag = 0
k = StretchBlt(disppic.hdc, 0, 0, disppic.Width, disppic.Height, backpic.hdc, exp_x0, exp_y0, x - exp_x0, y - exp_y0, &HCC0020) '(将虚线框内的图象放大到整个图象框)
disppic.Refresh
k = BitBlt(backpic.hdc, 0, 0, backpic.Width, backpic.Height, disppic.hdc, 0, 0, &HCC0020)
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
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
Dim exp_x0, exp_y0, k, flag
Sub Form_Load()
disppic.AutoRedraw = True
disppic.AutoSize = True
disppic.Picture = LoadPicture( "C:\Documents and Settings\temp.bmp ")
disppic.ScaleMode = 3 - pixel
backpic.AutoRedraw = True
backpic.AutoSize = True
backpic.Picture = LoadPicture( "C:\temp.bmp ")
backpic.ScaleMode = 3 - pixel
backpic.Visible = False
End Sub
'当鼠标按下时:
Private Sub disppic_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
flag = 1
exp_x0 = x
exp_y0 = y
disppic.DrawStyle = 4 '(图象框disppic的绘图模式设置为虚线)
End Sub
'当鼠标拖动时:
Private Sub disppic_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If flag = 1 Then
k = BitBlt(disppic.hdc, 0, 0, disppic.Width, disppic.Height, backpic.hdc, 0, 0, &HCC0020)
'(把前一次的虚线框擦掉)
disppic.Line (exp_x0, exp_y0)-(x, y), RGB(0, 0, 0), B '(化虚线框)
End If
End Sub
'当鼠标被放开时:
Private Sub disppic_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
flag = 0
k = StretchBlt(disppic.hdc, 0, 0, disppic.Width, disppic.Height, backpic.hdc, exp_x0, exp_y0, x - exp_x0, y - exp_y0, &HCC0020) '(将虚线框内的图象放大到整个图象框)
disppic.Refresh
k = BitBlt(backpic.hdc, 0, 0, backpic.Width, backpic.Height, disppic.hdc, 0, 0, &HCC0020)