65 int maplen, cmaplen, nmap;
72 for ( j = 1; j < nmap; j++ )
73 cmap[j] = cmap[j-1] + 256;
74 for ( i = 0; i < 256; i++ )
75 for ( j = 0; j < nmap; j++ )
98 for ( i = 1; i < nmap; i++ )
99 cmap[i] = cmap[0] + i * maplen;
102 for ( i = 0; i < maplen; i++ )
104 for ( j = 0; j < the_hdr
->ncmap; j++ )
106 cmap[j][i] = the_hdr
->cmap[j*cmaplen + i] >> 8;
109 for ( ; j < nmap; j++ )
110 cmap[j][i] = cmap[j-1][i];
115 if ( orig_gamma == 0 )
120 orig_gamma = atof( v );
122 if ( orig_gamma == 0.0 )
125 orig_gamma = 1.0 / orig_gamma;
127 else if ( (v =
rle_getcom( "display_gamma", the_hdr
)) != NULL)
129 orig_gamma = atof( v );
131 if ( orig_gamma == 0.0 )
139 if ( new_gamma != 0.0 )
140 gamma = orig_gamma / new_gamma;
147 for ( i = 0; i < 256; i++ )
148 gammap[i] = (
int)(0.5 + 255.0 * pow( i / 255.0, gamma ));
149 for ( i = 0; i < nmap; i++ )
150 for ( j = 0; j < maplen; j++ )
151 cmap[i][j] = gammap[cmap[i][j]];
rle_pixel ** buildmap(rle_hdr *the_hdr, int minmap, double orig_gamma, double new_gamma)
char * rle_getcom(char *name, rle_hdr *the_hdr) const