if there is an integer value, eg. 86 then how can i extraact the r,g,b components from this integer value….?
I am working on Visual C++ 2008 express edition.
Thanks..
if there is an integer value, eg. 86 then how can i extraact the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Usually (and I repeat usually, since you don’t specify much in your question) a color is packed in a 4-bytes integer with RGBA components.
What you need to do is mask and shift, for example:
This assumes the kind of encoding I specified, but can be modified according to yours.
EDIT:
In your example you spoke about a 0-255 value. It is not clear if components are 2bit sized (4 intensity values per component).
In that case the approach still remains the same but you will have just few colors:
EDIT2: Maybe your colors are indexed with palette, in that case you should have an array that stores the palette itself and the byte you read from the file should be the index of a color stored somewhere else.