How to test whether pixel is white in byte array?
问题 I'm trying to trim a Bitmap based on white pixels. I'd like to do it efficiently, so I'm avoiding using .GetPixel I'm implementing the marked-correct answer from this question. In the answer, they detect whether pixels in a byte array are transparent. I would like to detect whether the pixels are white instead, with a threshold (so if it is less white than a threshold then foundPixel=true; . I've extracted the relevant code here: static Bitmap TrimBitmap(Bitmap source) { BitmapData data =