Extracting individual bits from a byte

S

simonc

i'm trying to get the data out of a monochrome bmp file which has one bit per
pixel. I can read the byte containing 8 consecutive pixels but I'm getting
tied in knots trying to find the most efficient way of reading the individual
bits into an array.

Grateful for advice
 
R

Rick Rothstein

What kind of array are you trying to put it into and how many dimensions
does the array have, one or two (if one, how is the data laid out, column
first or row first)?
 
S

simonc

Thanks for this. It turns out And is the key.

To extract the eight bits of a byte I used

for i = 0 to 7
bit(i) = byte And 2^i
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top