本文介绍了有没有比 GDI GetPixel() 更快的替代方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 .NET 应用程序中使用来自 gdi32.dll 的 GetPixel() 对屏幕上任意位置的像素颜色进行采样.它工作正常,但对我来说是一个主要的性能瓶颈.

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.

有没有更快的方法?

推荐答案

使用 BitmapLockBits() 方法可以快速访问像素.这将返回给您一个包含指向像素数据开头的指针的对象,您可以使用不安全的代码来访问内存.

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.

https://web.archive.org/web/20150330113356/http://bobpowell.net/lockingbits.aspx

这篇关于有没有比 GDI GetPixel() 更快的替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:30