i've posted this on another website and no one could help
I'm trying to work with colors and before now oslib had #defines that did it for me but i'm using SDL and i need to know how to work with colors i know the basic RGBA stuff 0 to 255 but how are they combined to be in one int (ex Uint32) and be a color and then how do i extract the values from that also i looked it up but i see a bunch of rgb stuff, etc but nothing i'm looking for
what i'm wanting is to learn how they work when casting to an in say for instance i know i need a color RGB r = 255, b = 100, g = 30, a = 240
now how can i take all of those values and bit the or whatever i need to do to make them into a Uint32 that i can use that is a color that would be also useable on other systems also for future reference
i know somewhere i've seen something like
r << (sum num) << g (sum num) << ...
that i dont fully understand or remember but it made a color i believe that oslib uses this in #define's but dont understand it
thats about all that went on in that post summed up
working with colors
One eight-bit byte can store a value from 0 to 255.
The PSP uses integers that are 4 bytes, 32 bits.
The way you encode the colors depends on the pixel format you're using. Just realize that there are typically four channels in a color: red, green, blue, and alpha. But sometimes there're less.
To put it together, encoding a color that uses one byte per channel is as simple as using one byte per channel.
My advice is to read about bytes and integers, bit-shifting and logical operations, and the pixel format that you're wanting to encode to.
The PSP uses integers that are 4 bytes, 32 bits.
The way you encode the colors depends on the pixel format you're using. Just realize that there are typically four channels in a color: red, green, blue, and alpha. But sometimes there're less.
To put it together, encoding a color that uses one byte per channel is as simple as using one byte per channel.
My advice is to read about bytes and integers, bit-shifting and logical operations, and the pixel format that you're wanting to encode to.
cool thanks right direction after an hour got to this page cause one thing led to another and i found it thanks so much
http://hrboyceiii.blogspot.com/2007/02/ ... d-why.html
http://hrboyceiii.blogspot.com/2007/02/ ... d-why.html