#include <stdio.h>
#include "rle.h"
#include <math.h>
Go to the source code of this file.
Definition at line 56 of file buildmap.c.
Referenced by find_most_used().
67 if ( the_hdr->
ncmap == 0 )
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++ )
82 cmaplen = (1 << the_hdr->
cmaplen);
90 if ( nmap < the_hdr->ncmap )
91 nmap = the_hdr->
ncmap;
92 if ( nmap < the_hdr->ncolors )
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 )
118 if ( (v =
rle_getcom(
"image_gamma", the_hdr )) != NULL )
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]];
char * rle_getcom(const char *name, rle_hdr *the_hdr)
int gamma(int x, float gamma_value)