I am trying to write an SDL app that will load/view .SHP files. I wrote a
seperate app that reads the header and decompresses the file leaving just
the raw pixel data left. The value for each pixel is an index into a RGB
palette which specifies the color. This is similiar to how BMPs and PCX
files work. How can I load the image and then set the palette then update
the screen for it to display? The palette is in a seperate file, btw.
Thanks.
At 17:49 13/06/2000 Tuesday, you wrote:
I am trying to write an SDL app that will load/view .SHP files. I wrote a
seperate app that reads the header and decompresses the file leaving just
the raw pixel data left. The value for each pixel is an index into a RGB
palette which specifies the color. This is similiar to how BMPs and PCX
files work.
8 bit bmp/pcx yes.
How can I load the image and then set the palette then update
the screen for it to display? The palette is in a seperate file, btw.
try this:
{
// load image containing desired palette
SDL_Surface *palSurface = IMG_Load( palFName );
// set the screens palette if both are 8 bit.
if ( screenSurface->format->BitsPerPixel==8 &&
palSurface->format->BitsPerPixel==8 ) {
SDL_Palette *pal = palSurface->format->palette;
SDL_SetColors( screenSurface, pal->colors, 0, pal->ncolors );
}
SDL_FreeSurface(palSurface);
}
I just typed this up, so don't be too supprised if it doesn't compile. The
theory is what matters.
-dv