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 

Color problem

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



Joined: 31 Dec 2005
Posts: 288

PostPosted: Sat Feb 11, 2006 6:52 am    Post subject: Color problem Reply with quote

Hi folks,

I make my pictures with photoshop, with this i can specify the color as hex or a RGB value. however i have to specify the color in just an integer.

now i know that 0 = pure black and 16.700000 (rounded) is white but i can't seem to find a way to get right colors.

like say i have this heximal value if i convert it with the windows calculator to an integer the color is not the color i want.

Is there a way to convert a heximal value to an integer so it will be the same color?
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Sat Feb 11, 2006 7:19 am    Post subject: Reply with quote

It depends on the colorformat of the displaying application. For psp it would be BGR, meaning color = B << 16 | G << 8 | R, where R, G and B are each byte values in range 0-255, | means a logical OR and << N is a logical shift left by N bits. In readable mathematics it is the same as B * 65536 + G * 256 + R (note this is only correct in this special case, as OR is not the same as +). If you want to to create a corresponding hex value its just the same as writing each single component as hex value, which is then made of two values (0 = 00h, 255 = ffh) and append the hex values in the correct order, where B is leftmost and R would be rightmost.
Example: R 255 = HEX FF, G 127 = HEX 7F, B 128 = HEX 80, thus making a color of HEX 80 7F FF in BGR format. Reverting this process and then using above formula gives you a HEX->INT conversion.
However Photoshop uses RGB format, so if you want to specify a color there, you have R and B switched. This means if you want to display a picture made in photoshop (and saved in RGB mode, which is used in most image file formats) on your psp, you have to read in the colors and switch these two bytes to get the correct result.
Back to top
View user's profile Send private message Visit poster's website
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Sat Feb 11, 2006 7:56 am    Post subject: Reply with quote

Thanks that worked now the colors come out the way i want thanks
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
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