有没有更快的替代GDI与getPixel()?更快、GDI、getPixel

2023-09-02 21:31:13 作者:空了岛退了潮

我在.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

 
精彩推荐
图片推荐