Loading 1bit bitmap from byte array #1253
-
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? |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
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.