gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > palette question

#26119 - tomer - Wed Sep 08, 2004 8:36 am

Hi

I have 256 colors picture, and a palette.
How do I conert it to 15 bit picture?

thankx in advance

#26125 - FluBBa - Wed Sep 08, 2004 12:26 pm

Are you the same guy that have made a 3D engine?
Anyway, read a byte from your picture, use that value as a pointer into your palette (I suppose it's 15bit BGR for tha GBA), read the palette value, that is your new pixel to put in the picture.
Code:

u8 image_src[240*160];
u16 palette[256];
u16 picture_dst[240*160];

for(i=0;i<240*160;i++){
val=image_src[i];
pal=palette[val];
picture_dst[i]=pal;
}


And why are you double posting (again)?
_________________
I probably suck, my not is a programmer.

#26135 - tomer - Wed Sep 08, 2004 1:22 pm

yes I am the same guy who made the 3d engine.
thankx for your answer.
I am trying to save ROM memory, and so to convert
data to 256 color.