I'd just like to ask, and I thought this might as well go here in case it becomes a suggestion of change (not yet) -
What's the logic behind AGS' color system (high-colour modes), which uses a range of 0-31 RGB instead of a 0-255 RGB? Is there any difference, or is it just backward compatibility?
How do I found out which color in this system is the equal of, say, 123,132,312 (just made that up) in regular 255 RGB?
And vice versa?
QuoteHow do I found out which color in this system is the equal of, say, 123,132,312 (just made that up) in regular 255 RGB?
rawcolor = (2048*R) + (64*G) + B
Hi-colour is 16-bit colour, in which Red, Green and Blue are represented by 5 bits each.
Therefore the accuracy of the hi-color video mode is down to 32 shades of each component.
AGS then keeps this method of selecting colours for 32-bit to make porting your game between 16-bit and 32-bit as painless as possible.
Quote from: strazer on Fri 20/05/2005 20:09:28
QuoteHow do I found out which color in this system is the equal of, say, 123,132,312 (just made that up) in regular 255 RGB?
rawcolor = (2048*R) + (64*G) + B
Well, he asked for a conversion that would go from "255 RGB" to rawcolour.
This should work better.
// first convert from 0-255 to 0-31
int r32 = R/8;
int g32 = G/8;
int b32 = B/8;
// then
rawcolour = (2048*r32) + (64*g32) + b32
Thank you, but for the use I'll give it all I needed to know was that I can divide each number by 8 and use the resulting settings - that IS right, isn't it?
Nevertheless, I'll keep the rest in mind. But BTW,
Quoterawcolour = (2048*r32) + (64*g32) + b32
this is the internal calculation AGS does, right? I mean, in order to come up with the final number, this is what AGS does from the RGB values I set?
Forgive me for being thick - my GCSE maths is failing me.
How would you go about finding the reverse, i.e. the RGB 0-31 values from the 16bit rawcolour? I'm guessing it will require some sort of Bitwise shifting?
red = (raw >> 11) % 32
green = ((raw >> 5) % 64) / 2
blue = raw % 32
Superb, works a treat. Thanks Chris.