Repository navigation
Loading 1bit bitmap from byte array #1253
Answered
by
brianpopow
Int32Overflow
asked this question in
Q&A
|
Hello, I have a 1bit bitmap which is stored in a byte array. That means 1 byte has 8 pixels. How can I load this array as an image? |
Answered by
brianpopow
Jul 5, 2020
Replies: 1 comment 2 replies
|
ImageSharp can decode 1bit bitmaps, but the bitmap needs to have a valid bitmap header (a valid file header and a valid bitmap header). This contains information on how the data has to be interpreted. One example 1bit bitmap would be this If that's the case for your byte array just use:
If that's not the case you would need to prepend a valid bitmap header, but i guess that's too cumbersome. |
2 replies
Answer selected by
Int32Overflow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ImageSharp can decode 1bit bitmaps, but the bitmap needs to have a valid bitmap header (a valid file header and a valid bitmap header). This contains information on how the data has to be interpreted. One example 1bit bitmap would be this
If that's the case for your byte array just use:
using (var image = Image.Load(byteArray))If that's not the case you would need to prepend a valid bitmap header, but i guess that's too cumbersome.