以下程序可以将屏幕图片位图数据拷贝到内存环境中,然后进行处理。 不过我用getpixel写了个找色程序,好像比在屏幕设备中找色要慢,搞不懂,留着以后慢慢研究吧。
Dim hDCMemory As Long
Dim hBmp As Long
Dim hBmpPrev As Long
' Depending on the value of Client get the proper device context.
hDCSrc = hWndSrc
' Create a memory device context for the copy process.
hDCMemory = CreateCompatibleDC(hDCSrc)
' Create a bitmap and place it in the memory DC.
hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
hBmpPrev = SelectObject(hDCMemory, hBmp)
r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy)
hBmp = SelectObject(hDCMemory, hBmpPrev)
' Release the device context resources back to the system.
r = DeleteDC(hDCMemory)
r = ReleaseDC(hWndSrc, hDCSrc)

该程序示例展示了如何将屏幕图像复制到内存并进行处理。尽管使用getpixel进行找色操作在速度上可能较慢,但其提供了在内存环境中处理图像的基础,适合后续研究和优化。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



