Date: 1998jun1
Language: C/C++
Q. C/C++: Make the Netscape palette before making a GIF
A.
const int N_NETSCAPE_PALETTE = 216;
void MakeNetscapePalette(GifColorType *colors, const int nColors) {
const BYTE a[6] = { 0, 0x33, 0x66, 0x99, 0xcc, 0xff };
int red, green, blue;
int i = 0;
for (red = 0; red < 6; red++) {
for (green = 0; green < 6; green++) {
for (blue = 0; blue < 6; blue++) {
colors[i].Red = a[red];
colors[i].Green = a[green];
colors[i].Blue = a[blue];
i++;
}
}
}
for (; i < nColors; i++) {
colors[i].Red = 0;
colors[i].Green = 0;
colors[i].Blue = 0;
}
}
void exampleUse() {
const int nColors = 256;
if ((color_map = MakeMapObject(nColors, NULL)) == NULL) {
return;
}
MakeNetscapePalette(color_map->Colors, nColors);
}