Manipulating bits in 1Bpp Bitmap class

  • Thread starter Thread starter James Dean
  • Start date Start date
J

James Dean

Could anybody tell me the most efficient way to set the bits in a 1Bpp
class. I am reading in byte lines of an image. The byte array tells me
what what bits are turned on or off.....i do bit masking to get the
colour....i can just convert the whole Line byte array to a
bitarray.....Also i have trouble about how to set the pointer to point
at a bit instead of a byte.....when i lock the the bits i want the
pointer pointing at a bit not a byte....is this possible?. I want to
lock the bits first then have a pointer to all the locked data......then
have an efficient function for reading in the bytes and setting the
required bits.



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
James,
Sorry I can't help you with your problem, but I am fairly certain that you
can't use a bit as a data type in any .NET language. The only language I've
heard of that allows this is D (http://www.digitalmars.com/d).

Chris
 
You cannot have a pointer pointing to a bit since bytes is the smallest
addressable unit.
But you can maipulate certain bits in a byte using bitwise operators. for
example:

byte b = 123;

b&= ~(1<<4);

removes the 4th bit from b. And the following line:

b|= (1<<2);

sets the 2nd bit in the byte to true. btw, the bit count starts with zero.
 
Back
Top