请大家帮忙看看 图像局部放大的程序,为什么结果不对呢
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)
'(让图象框backpic保存放大后的图象)
disppic.DrawStyle = 0
End Sub
鼠标选取区域后,发现就花瓶了,不能实现局部放大的效果,不知怎么回事?
[解决办法]
去看一下vb编程实例100那本书,实现放大镜
没环境,没法试一下
[解决办法]
图像处理并不是vb的长项,处理速度有问题。,
你的代码我没看,不过我知道用paintpicture实现缩放,代码要比你这简单好多
[解决办法]
///图像处理并不是vb的长项,处理速度有问题。,
前面一句我局部同意,后面的处理速度我不同意你的说法,因为用模拟指针和Dibsection相结合的处理速度和VC的差距不大。
