forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

working with colors

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Sat Jun 20, 2009 9:54 am    Post subject: working with colors Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
svxs



Joined: 19 Jun 2009
Posts: 15

PostPosted: Sat Jun 20, 2009 2:11 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Sat Jun 20, 2009 7:55 pm    Post subject: Reply with quote

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/bit-shifting-what-is-it-and-why.html
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group