Anisha
asked on
Using Bit fields
Hi!
I m back again with a another query , before that i must say God bless the team who thought of this site, has helped me a lot during my studies, i m contributing my bit by recomending it to my friends.
Getting back to my query, i want to create a mask for a p'cular color in an image , now i create this mask by creating a char array of the iamge size and using it for storing 1s for the corresponding color and 0s otherwise. This is not a problem , the problem is that just to store 1 bit data i m using 8bits(byte of a char) , i was suggested to use bit fields but then i cannot create an array of bitfield structure and since the image size varies i cannot predefine it. Please help
Anisha.
I m back again with a another query , before that i must say God bless the team who thought of this site, has helped me a lot during my studies, i m contributing my bit by recomending it to my friends.
Getting back to my query, i want to create a mask for a p'cular color in an image , now i create this mask by creating a char array of the iamge size and using it for storing 1s for the corresponding color and 0s otherwise. This is not a problem , the problem is that just to store 1 bit data i m using 8bits(byte of a char) , i was suggested to use bit fields but then i cannot create an array of bitfield structure and since the image size varies i cannot predefine it. Please help
Anisha.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
pjknibbs,
thanks for the sugestion but i have kept that as an alternative, but i would really wait and see if someone can help me with bitfields , life will be easier then.
Anisha.
thanks for the sugestion but i have kept that as an alternative, but i would really wait and see if someone can help me with bitfields , life will be easier then.
Anisha.
I agree with ct.smith. You should use the bitset container.
Dear Anisha
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity, I will suggest to accept
"ct.smith"
comment(s) as an answer.
If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: https://www.experts-exchange.com/commspt/
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity, I will suggest to accept
"ct.smith"
comment(s) as an answer.
If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points. The link to the Community Support area is: https://www.experts-exchange.com/commspt/
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Force accepted
** Mindphaser - Community Support Moderator **
** Mindphaser - Community Support Moderator **
e.g. to set bit 370 in an array: array[370>>3] |= (1 << (370 & 7));