有没有更快的替代GDI与getPixel()? [英] Is there a faster alternative to GDI GetPixel()?
本文介绍了有没有更快的替代GDI与getPixel()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在.NET应用程序中使用与getPixel()
从GDI32.DLL到屏幕上的任意位置取样像素的颜色。它的工作原理确定,但它是我的一个主要性能瓶颈。
I'm using GetPixel()
from gdi32.dll in a .NET app to sample the colour of a pixel anywhere on the screen. It works ok but it is a major performance bottleneck for me.
有没有做这件事的一个更快的方法?
Is there a faster way of doing it?
推荐答案
快速访问像素可以使用 LockBits()
的方法的位图
。这将包含一个指向的对象返回到你的像素数据的开始,你可以使用不安全code来访问内存。
Fast access to pixels are possible using LockBits()
method of the Bitmap
. This will return to you an object containing a pointer to the start of the pixel data and you can use unsafe code to access the memory.
http://www.bobpowell.net/lockingbits.htm
这篇关于有没有更快的替代GDI与getPixel()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文