Mail Archives: djgpp/1997/01/20/11:55:26
> Has anybody created a good palette for allegro. I noticed that the
> palette contains the same 16 colors at all the 256 places.
>
> An even better solution would be an algorithm to choose rgb values
I use a paint program to edit or load palettes, then I save blank pcx
files and save the palette to the pcx file. Then I use this function I
wrote to extract the palette from the pcx and load that in:
// use it for whatever you want. It should work, but this isnt the
// computer I have djgpp on, so the 8bit to 6bit conversions may be
// incorrectly done -- sorry
void get_pcx_palette(char* filename)
{
// extracts the palette from a pcx file
// pal is an array of 256 rgb unsigned char values - pal.r pal.g pal.b
FILE *pcxfile = fopen(filename, "rb"); // open pcx file
int index;
PALETTE pal;
fseek(pcxfile, -768, SEEK_END); // go to 768 bytes before end
of file
for (index = 0; index < 256; index++)
{
pal[index].r = getc(pcxfile);
pal[index].g = getc(pcxfile);
pal[index].b = getc(pcxfile);
}
set_palette(pal);
}
// thats it it should work, call "get_pcx_palette("your_pic.pcx");"
--
Rob Vasquez
Digital Fx '97
email: digital DOT fx AT worldnet DOT att DOT net
- Raw text -