FILE *fp;
Uint8 palette[256][3];
SDL_Color colors[256];
int i;
// Open our ACT file
fp = fopen( "palette.act", "rb" );
if ( !fp )
{
fprintf( stderr, "File could not be opened... :(" );
}
// Read the entire contents of the file into our palette array
fread( palette, 3, 256, fp );
fclose( fp );
// Copy the palette values to our SDL_Color array
for ( i = 0; i < 256; i++ )
{
colors[i].r = palette[i][0];
colors[i].g = palette[i][1];
colors[i].b = palette[i][2];
}
// Set the palette for some surface
SDL_SetPalette( someSurface, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);