I was wondering why the hex codes for colours on the psp are different from on pc. I am using SDL in 2.01 firmware.
thanks
hex codes for colours
Depends what colour depth you're using, in HEX each pair of letters represents 2 bytes or 8 bits, or 0-255 in DEC. The PSP uses whatever colour depth you've set, it can be anything for textures* but printing to the screen should be in 16 or 32 bit, web colours are defined as 24 bit which I imagine is the source of your confusion.
@16 bit you can have: 0x0000 to 0xFFFF (this is harder to read because the middle two bytes contribute to both the R and G, and, G and B values respectively, and each individual value of R,G or B can only be 0-31. Unless you're also using alpha, in which case each byte corresponds to a colour directly RGBA with the last being the alpha byte)
@24 bit you can have: 0x000000 to 0xFFFFFF (I presume this is what you mean by 'PC' colours).
@32 bit you can have: 0x00000000 to 0xFFFFFFFF (the last 8 bits are for alpha)
@16 bit you can have: 0x0000 to 0xFFFF (this is harder to read because the middle two bytes contribute to both the R and G, and, G and B values respectively, and each individual value of R,G or B can only be 0-31. Unless you're also using alpha, in which case each byte corresponds to a colour directly RGBA with the last being the alpha byte)
@24 bit you can have: 0x000000 to 0xFFFFFF (I presume this is what you mean by 'PC' colours).
@32 bit you can have: 0x00000000 to 0xFFFFFFFF (the last 8 bits are for alpha)
I dunno. When I wanted to load a color from an INI file and use it in the graphics.cpp file from Lua the color I had to use was '16777215' for pure white.
#define RGB(r, g, b) ((b << 16) | (g << 8) | r)
#define WHITE RGB(255, 255, 255)
And then I just did a printf("%d", WHITE);
Perhaps it's just the way I did the output, but when I feed that number as an int to graphics.cpp it works.
#define RGB(r, g, b) ((b << 16) | (g << 8) | r)
#define WHITE RGB(255, 255, 255)
And then I just did a printf("%d", WHITE);
Perhaps it's just the way I did the output, but when I feed that number as an int to graphics.cpp it works.
Wil
Code: Select all
I was wondering why the hex codes for colours on the psp are different from on pc. I am using SDL in 2.01 firmware.
thanks
For PSP you have a macro:
#define BGR(r,g,b) (r | g << 8 | b << 16)
while for PC you'd have:
#define RGB(r,g,b) (r << 16 | g << 8 | b)
all respectively to a 32/24bit framebuffer.
@fish: one pair of letters is 1 byte == 8bit