0

I want to search in an image for pixels above or below a certain value once that image has been read from a file and converted to a byte array. The Count method for a byte array is quite fast:

int numHighSaturatedPixels = imageArray.Count(n => n == highThreshold)

but the header information from the image format (BMP in my case) is still in there and is included in the count. How can the image be converted to a byte array without the header data getting in there?

4
  • See this answer in the question you already looked at. That uses the WPF API. I've added other duplicates that include GDI+ and LockBits as well, since it's not clear in your question which API you want to use. Commented Mar 6, 2021 at 21:15
  • Oops, sorry for the confusion, I'm using WinForms. The CopyPixels method isn't in Bitmap in that case. Commented Mar 6, 2021 at 21:53
  • That's okay... you can still use the other methods, like LockBits(). Commented Mar 6, 2021 at 22:33
  • Tried the solution suggested by @PeterDuniho and it works perfectly. This page has a good example that I followed. Thanks, Peter! Commented Mar 7, 2021 at 20:17

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.