Palette format
Posted: Wed Jan 12, 2011 10:51 pm
I'm trying to create my own sprite palettes which I can copy over the palette that grit creates but I'm not sure about the format.
The image file I'm using is a 32x32 PNG with a 16 colour indexed palette created with Photoshop. The grit switch file I'm using is
I tried to create an array to replace the palette supplied with the grit conversion of my image. I couldn't really find much information on the palette format but in the libnds example "Graphics/Sprites/sprite_extended_palettes/source/template.c" the palette elements seem to be two byte (u16 type) or rather 15 bit colour codes. Apparently you can use the macro RGB15(r,g,b) to create a colour entry (though it might be only for the extended palette, I'm not sure...).
However when I tried copying the following array
with this function call
all sprite pixels, except the pixels set in the PNG as transparent, were black.
I assumed the palette created would have 16 colours but when I looked at the header file it creates, the palette is 256, not 16
So I'm pretty confused. Can anyone in the know help me out?
The image file I'm using is a 32x32 PNG with a 16 colour indexed palette created with Photoshop. The grit switch file I'm using is
Code: Select all
# Set the warning/log level to 3
-W3
# Tell grit to include a palette (the first index in it will be transparent)
-p
# Tile the image
-gt
# Set the bit depth to 4 (16 colors)
-gB4
However when I tried copying the following array
Code: Select all
uint16 spherePalRed[16] = { 0, RGB15(29,0,0), RGB15(27,0,0), RGB15(25,0,0),
RGB15(23,0,0), RGB15(21,0,0), RGB15(19,0,0), RGB15(17,0,0),
RGB15(15,0,0), RGB15(13,0,0), RGB15(11,0,0), RGB15(9,0,0),
RGB15(7,0,0), RGB15(5,0,0), RGB15(3,0,0), RGB15(31,0,0) };
Code: Select all
dmaCopyHalfWords(SPRITE_DMA_CHANNEL,
&spherePalRed,
&SPRITE_PALETTE[nextAvailableSpriteNum * COLORS_PER_PALETTE],
COLORS_PER_PALETTE);
I assumed the palette created would have 16 colours but when I looked at the header file it creates, the palette is 256, not 16
Code: Select all
// sphereWhite, 32x32@4,
// + palette 256 entries, not compressed
// + 16 tiles not compressed
// Total size: 512 + 512 = 1024