Jessica Boxer
Jessica Boxer

Reputation: 543

How to determine if a pixel in a GIF is transparent (.NET)

How can I determine if a particular pixel in a GIF image is transparent in C#? I can see the MakeTransparent method in Bitmap, but nothing to determine if it is actually transparent already.

Thanks.

Upvotes: 1

Views: 1801

Answers (1)

driis
driis

Reputation: 164301

Use GetPixel and then look at the Alpha component of the Color instance returned. 0 = fully transparent.

If you need to loop through all (or many) pixels, be aware that GetPixel is quite slow. A faster, but more involved way, is to use LockBits to lock the data in memory, then look at the bitmap data directly.

Upvotes: 5

Related Questions