抓一张图放在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

解决方案 »

  1.   

    ReDim ByteAry(totbyte - 1)    (调式后 说这“下标越界”)
    totbyte - 1是否已经超过60,最多可以定义 60 维的多维数组
      

  2.   

    毕业设计不会做、害怕答辩通不过……不要紧,有我们会帮你解决这一切!我们提供专业的计算机毕业设计和课程设计。我们可以根据您的要求,特别为您量身定做毕业设计(绝对是原创!)。并且会在程序代码里写出很详细的注释,同时也能帮您学习编程。
    有需要者登录http://xdqbysj.10mb.cn/
    QQ:
    客服一(16376208)  客服二(57293694)