Question: AGS's color system

Started by Rui 'Trovatore' Pires, Fri 20/05/2005 19:15:26

Previous topic - Next topic

Rui 'Trovatore' Pires

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?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

strazer

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

Pumaman

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.

Kweepa

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
Still waiting for Purity of the Surf II

Rui 'Trovatore' Pires

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?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Clarvalon

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?
XAGE - Cross-Platform Adventure Game Engine (alpha)

Pumaman

red = (raw >> 11) % 32
green = ((raw >> 5) % 64) / 2
blue = raw % 32

Clarvalon

Superb, works a treat.  Thanks Chris.
XAGE - Cross-Platform Adventure Game Engine (alpha)

SMF spam blocked by CleanTalk