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 

[SOLVED] RGB to u32 Color

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



Joined: 16 Jan 2008
Posts: 7

PostPosted: Fri Feb 29, 2008 3:58 am    Post subject: [SOLVED] RGB to u32 Color Reply with quote

Hi,

Yeah, I'm noob, but I don't know how to convert an RGB colour to an u32 colour.

I get the framebuffer with 'sceDisplayGetFrameBuf', and I want to change the colour of some pixels.

With SDL there is the function 'SDL_MapRGBA' but I don't want to use SDL. And there isn't the 'uint32_pack' for the PSP (or I didn't find it)

Can someone help me ? :(

Solution :
Code:
color = (b<<16) + (g<<8) + r;
Back to top
View user's profile Send private message
CpuWhiz



Joined: 04 Jun 2007
Posts: 42

PostPosted: Fri Feb 29, 2008 2:34 pm    Post subject: Reply with quote

They are in pspgu.h:
Code:
/* Color Macros, maps 8 bit unsigned channels into one 32-bit value */
#define GU_ABGR(a,b,g,r)   (((a) << 24)|((b) << 16)|((g) << 8)|(r))
#define GU_ARGB(a,r,g,b)   GU_ABGR((a),(b),(g),(r))
#define GU_RGBA(r,g,b,a)   GU_ARGB((a),(r),(g),(b))

/* Color Macro, maps floating point channels (0..1) into one 32-bit value */
#define GU_COLOR(r,g,b,a)   GU_RGBA((u32)((r) * 255.0f),(u32)((g) * 255.0f),(u32)((b) * 255.0f),(u32)((a) * 255.0f))


So:
Code:
color = GU_RGBA(r, g, b, 255);
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