开发者

Faster method to loop through image

Does anyone knows how to get this work faster? Can i do the same by using Lockbits?

for (int y = 0; y < picture.Height; y++)
{
    for (int x = 0; x < picture.Width; x++)
    {
         Color colorPixel = picture.GetPixel(x, y);

         if ((colorPixel.A > 230) &&
            (colorPixel.R < 20) &&
            (colorPixel.G < 20) &&
            (colorPixel.开发者_StackOverflow中文版B < 20))
            {
                    //do something
            }

Thanks.


Here's a post about comparing to images in C# quite fast. It starts out with a pretty slow version (which is still better than GetPixel) and ends up with a version that is 25 times as fast:

http://danbystrom.se/2008/12/14/improving-performance/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜