473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Manipulating bits in 1Bpp Bitmap class

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!
Nov 16 '05 #1
2 2764
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

"James Dean" <m_*******@yahoo.com> wrote:
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.

Nov 16 '05 #2
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.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"James Dean" <m_*******@yahoo.com> schrieb im Newsbeitrag
news:#w*************@TK2MSFTNGP10.phx.gbl...
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!

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Kristian Nybo | last post by:
Hi, I'm writing a simple image file exporter as part of a school project. To implement my image format of choice I need to work with big-endian bytes, where 'byte' of course means '8 bits', not...
1
by: James Dean | last post by:
How do i create a 1bpp png if i have the 1bpp data stored in a byte array.... *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for...
3
by: James Dean | last post by:
I have read that you can create a 1bpp png image but has anyone any idea how to do it?...... *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in...
0
by: James Dean | last post by:
I save a 1bpp bitmap as a 1bpp png......i save this 1bpp png in a memorystream.....problem is i want to convert this back to a 1bpp bitmap but it always saves as a 32bpp bitmap....i need the 1bpp...
21
by: felixnielsen | last post by:
If im not mistaken, a char variable allocates 1 byte of memory, as it is the case with a bool variable. I need 2 bool and 1 char variable which only need to contain a value between 0 and 63...
7
by: Fir5tSight | last post by:
Hi All, I used the following code in C#: using System.Drawing; //blah blah blah Bitmap bmp = new Bitmap();
0
by: benfly08 | last post by:
Hi, guys. I have a program to draw bar/pie chart based on the data i hard coded in it. However, my image comes with "BLACK" background color. I don't know how to fix this. The code snippet is...
8
by: Frank | last post by:
Given a bitmap I want to write a Icon file using it. I believe I can do it except for writing the bits of the image. Can you tell me how to get the bits into a ByteArray Thanks
1
by: davidpryce123 | last post by:
Dear Group. For an application I am developing I need to display a 64 bit bitmap as a compressed ascii string of bits. This is to allow for the easier understanding of the bits for the users....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.