How can I iterate through each pixel in a .gif image?

前端 未结 3 1517
礼貌的吻别
礼貌的吻别 2020-12-09 05:04

I need to step through a .gif image and determine the RGB value of each pixel, x and y coordinates. Can someone give me an overview of how I can accomplish this? (methodolo

3条回答
  •  难免孤独
    2020-12-09 05:26

    You can load the image using new Bitmap(filename) and then use Bitmap.GetPixel repeatedly. This is very slow but simple. (See Vinko's answer for an example.)

    If performance is important, you might want to use Bitmap.LockBits and unsafe code. Obviously this reduces the number of places you'd be able to use the solution (in terms of trust levels) and is generally more complex - but it can be a lot faster.

提交回复
热议问题