 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
_BenJi
Joined: 16 Jan 2008 Posts: 7
|
Posted: Fri Feb 29, 2008 3:58 am Post subject: [SOLVED] RGB to u32 Color |
|
|
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 |
|
 |
CpuWhiz
Joined: 04 Jun 2007 Posts: 42
|
Posted: Fri Feb 29, 2008 2:34 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|