抓一张图放在PicBoX控件里 然后判断图片是否有我想要的点 但是图片可以抓 抓完就报错"下标越界" 另外请看下还有
其他的错误吗 这几天睡觉想 走路想 吃饭也想 总算把代码写的完整点了 可还是出错 原先用Point读点 可是很慢
还请各位高手多多指点 要不我还得受煎熬:cryhard
Option Explicit
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) 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
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Const Srccopy = &HCC0020
Dim hBitmap As Long
Dim res As Long
Dim bmp As BITMAP
Dim ByteAry() As Byte
Dim c() As Long
Dim totbyte As Long, i As Long
Private Sub Command1_Click()
Dim e As Integer, m As Integer, s As Long, sFile As String, f As Long, Dhdc As String
Sleep (3000)
hWnd = GetForegroundWindow()
Dhdc = GetWindowDC(hWnd)
StretchBlt boy.hdc, 0, 0, 300, 300, Dhdc, 0, 0, 300, 300, Srccopy
sFile = "d:\tp.BMP"
SavePicture boy.Image, sFile
hBitmap = boy.Picture.Handle
res = GetObject(hBitmap, Len(bmp), bmp)
totbyte = bmp.bmWidthBytes * bmp.bmHeight
ReDim ByteAry(totbyte - 1) (调式后 说这“下标越界”)
res = GetBitmapBits(hBitmap, totbyte, ByteAry(0))
Picture1.Scale (0, 0)-(bmp.bmWidth, bmp.bmHeight)
ReDim c(bmp.bmWidth, bmp.bmHeight - 1)
s = -3
f = -1
For e = 0 To bmp.bmHeight - 1 (这个循环是先把转换成RGB值 在下面的循环里对比RGB值 在这
For m = 0 To bmp.bmWidth - 1 转换完以后再对比RGB值就不用转了)
s = s + 3
f = f + 1
If s = res Then Exit For
c(f) = ByteAry(s) + ByteAry(s + 1) * 256 + ByteAry(s + 2) * 65536
End If
Next m
Next e
f = -1 (这个循环就是对比RGB值了)
For e = 0 To bmp.bmHeight - 1
For m = 0 To bmp.bmWidth - 1
f = f + 1
If c(f) = 16317688 Then
Print e
Print m
End If
Next m
Next e End Sub
其他的错误吗 这几天睡觉想 走路想 吃饭也想 总算把代码写的完整点了 可还是出错 原先用Point读点 可是很慢
还请各位高手多多指点 要不我还得受煎熬:cryhard
Option Explicit
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) 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
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Const Srccopy = &HCC0020
Dim hBitmap As Long
Dim res As Long
Dim bmp As BITMAP
Dim ByteAry() As Byte
Dim c() As Long
Dim totbyte As Long, i As Long
Private Sub Command1_Click()
Dim e As Integer, m As Integer, s As Long, sFile As String, f As Long, Dhdc As String
Sleep (3000)
hWnd = GetForegroundWindow()
Dhdc = GetWindowDC(hWnd)
StretchBlt boy.hdc, 0, 0, 300, 300, Dhdc, 0, 0, 300, 300, Srccopy
sFile = "d:\tp.BMP"
SavePicture boy.Image, sFile
hBitmap = boy.Picture.Handle
res = GetObject(hBitmap, Len(bmp), bmp)
totbyte = bmp.bmWidthBytes * bmp.bmHeight
ReDim ByteAry(totbyte - 1) (调式后 说这“下标越界”)
res = GetBitmapBits(hBitmap, totbyte, ByteAry(0))
Picture1.Scale (0, 0)-(bmp.bmWidth, bmp.bmHeight)
ReDim c(bmp.bmWidth, bmp.bmHeight - 1)
s = -3
f = -1
For e = 0 To bmp.bmHeight - 1 (这个循环是先把转换成RGB值 在下面的循环里对比RGB值 在这
For m = 0 To bmp.bmWidth - 1 转换完以后再对比RGB值就不用转了)
s = s + 3
f = f + 1
If s = res Then Exit For
c(f) = ByteAry(s) + ByteAry(s + 1) * 256 + ByteAry(s + 2) * 65536
End If
Next m
Next e
f = -1 (这个循环就是对比RGB值了)
For e = 0 To bmp.bmHeight - 1
For m = 0 To bmp.bmWidth - 1
f = f + 1
If c(f) = 16317688 Then
Print e
Print m
End If
Next m
Next e End Sub
解决方案 »
- TDBGrid满页后如何让光标继续下移;急~~~~~~
- 報表問題_水晶高手請進
- 二进制文件通过串口发送的问题
- 那里有vb的sp5补钉下载啊?
- 为什么我在窗体载入过程中用print会没有效果,并且也没有显示出错
- 请问大家:我的电脑是ADSL拔号上网的,怎样才能用VB实现拔号和连通立即计时功能啊??
- ===向DataEnvironment(1)传递参数(2)SQL语句(3)于ADODC或者RS绑定===
- 哪位有Tdbgrid8.0注册码?
- 请问如何通过程序将WinZip包解开!紧急求救!
- 很急的问题,请各位高手帮忙看看,关于文件格式转换的(dat/txt转换成dbf)。
- 如何使VB窗体位置后
- 挑战性的难题(vb调用ADO数据集)
totbyte - 1是否已经超过60,最多可以定义 60 维的多维数组
有需要者登录http://xdqbysj.10mb.cn/
QQ:
客服一(16376208) 客服二(57293694)