Changeset 2846 for libpipi/trunk/pipi/pixels.c
- Timestamp:
- 09/28/08 19:01:56 (5 years ago)
- File:
-
- 1 edited
-
libpipi/trunk/pipi/pixels.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/pixels.c
r2844 r2846 29 29 #include "pipi_internals.h" 30 30 31 #define GAMMA 1.032 33 31 static void init_tables(void); 32 33 static double global_gamma = 2.2; 34 static int done = 0; 34 35 35 36 static float u8tof32_table[256]; 36 37 static inline float u8tof32(uint8_t p) { return u8tof32_table[(int)p]; } 37 38 38 39 39 /* Return a direct pointer to an image's pixels. */ … … 153 153 if(p < 0.) d = 0.; 154 154 else if(p > 1.) d = 255; 155 else d = (int)(255.999 * pow(p, 1. / GAMMA));155 else d = (int)(255.999 * pow(p, 1. / global_gamma)); 156 156 157 157 dest[4 * (y * img->w + x) + i] = d; … … 189 189 if(p < 0.) d = 0.; 190 190 else if(p > 1.) d = 255; 191 else d = (int)(255.999 * pow(p, 1. / GAMMA));191 else d = (int)(255.999 * pow(p, 1. / global_gamma)); 192 192 193 193 dest[3 * (y * img->w + x) + i] = d; … … 252 252 } 253 253 254 void pipi_set_gamma(double g) 255 { 256 if(g > 0.) 257 { 258 global_gamma = g; 259 done = 0; 260 } 261 } 254 262 255 263 static void init_tables(void) 256 264 { 257 static int done = 0;258 265 int i; 259 266 … … 262 269 263 270 for(i = 0; i < 256; i++) 264 u8tof32_table[i] = pow((double)i / 255., GAMMA);271 u8tof32_table[i] = pow((double)i / 255., global_gamma); 265 272 266 273 done = 1; 267 274 } 275
Note: See TracChangeset
for help on using the changeset viewer.
