9 PALETTE default_palette=defarray;
10 PALETTE read_palette(FILE *f)
11 /* þÉÔÁÅÔ ÐÁÌÉÔÒÕ ÉÚ ÆÁÊÌÁ × ÆÏÒÍÁÔÅ EPPL7 */
14 pal=memcpy(malloc(256*sizeof(long int)),default_palette,256*sizeof(long int));
16 if (fscanf(f,"%d %d %d %d\n",&index,&r,&g,&b)!=4) break;
17 if (index>255) continue;
18 pal[index]=(r*255/1000)<<16|(g*255/1000)<<8|(b*255/1000);
23 char *ppm_pixel(PALETTE palette,int index)
25 static char buffer[24];
26 if(index>=0&&index<255)
28 else value=palette[255];
29 sprintf(buffer,"%d %d %d ",value>>16,(value>>8)&0xFF,value & 0xFF);
33 char *Xcolor_string(PALETTE palette,int index)
35 static char buffer[24];
36 if(index>=0&&index<255)
37 value=palette[index]; else value=palette[255];
38 sprintf(buffer,"#%06x",value);
41 XColor Xcolor_struct(PALETTE palette,int index)
44 if (index>=0&&index<255)
45 value=palette[index]; else value=palette[255];
47 buffer.green=(value>>8)&0xFF;
48 buffer.blue=value&0xFF;
49 buffer.flags=DoRed|DoGreen|DoBlue;