Reputation: 38
I want to read a pbm (portable bitmap format) image having depth one bit per pixel and store that data in a file, so I can perform some operation on bits.
I think in C# the smallest data that can be read is 1 byte so how can I read a bit?
Upvotes: 1
Views: 785
Reputation: 133950
You can't read a bit directly. But you can read a byte and then get the bits from that byte. Or, better yet, read a bunch of bytes into an array and then create a BitArray.
Or ... is this "portable bitmap format" supported directly by the Bitmap class? Bitmap
does support a 1 bit per pixel format. It might be as simple as calling the Bitmap
constructor to load from a file or a stream.
More information on your problem will get you a better answer.
Upvotes: 3