What's an efficient way to tell if a bitmap is entirely black?

前端 未结 12 914
清酒与你
清酒与你 2021-02-05 05:40

I\'m wondering if there\'s a super-efficient way of confirming that an Image object references an entirely black image, so every pixel within the bitmap is ARGB(255, 0, 0, 0).

12条回答
  •  孤街浪徒
    2021-02-05 06:25

    To be entirely sure of the image's blackness, you will have to check every pixel, and accessing the pixel data in an unsafe block is likely the fastest way to do it. Of course it's possible to optimize for the non-black case and try to find those earlier, but in the worst case you'll always have to check each and every pixel.

提交回复
热议问题