How do you store 3 numbers in a single byte using bit shifting in java, ie use the first 3 bits for R, the next 3 bits for G, and the last 2 bits B. I think I know how to retrieve the numbers from the bytes, however an example with encoding and decoding would be great.
Thanks Jake
EDIT:
The range of the values for R and G would be 0-7 and 0-3 for B.
Given
r
,g
andb
are in the range 0 - 255:This is filling out the result in this order:
i.e. I've assumed that when you've said "first" you meant least significant. If you want them the other way around it would be: