The PNG Guide is an eBook based on Greg Roelofs' book, originally published by O'Reilly. |
![]() |
Home ![]() ![]() |
|
![]() ![]() ![]() ![]() ![]() ![]() |
|
Gamma Correctiondouble default_gamma = 0.0; #if defined(NeXT) default_exponent = 1.0; /* 2.2/next_gamma for 3rd-party utils */ #elif defined(sgi) default_exponent = 1.3; /* default == 2.2 / 1.7 */ /* there doesn't seem to be any documented function to get the * "gamma" value, so we do it the hard way */ if (tmpfile = fopen("/etc/config/system.glGammaVal", "r")) { double sgi_gamma; fgets(fooline, 80, tmpfile); fclose(tmpfile); sgi_gamma = atof(fooline); if (sgi_gamma > 0.0) default_exponent = 2.2 / sgi_gamma; } #elif defined(Macintosh) default_exponent = 1.5; /* default == (1.8/2.61) * 2.2 */ /* if (mac_gamma = some_mac_function_that_returns_gamma()) default_exponent = (mac_gamma/2.61) * 2.2; */ #else default_exponent = 2.2; /* assume std. CRT, no LUT: most PCs */ #endif default_gamma = 1.0 / default_exponent; if ((p = getenv("SCREEN_GAMMA")) != NULL) { double exponent = atof(p); if (exponent > 0.0) default_gamma = 1.0 / atof(p); } The first section calculates a platform-dependent exponent for the display system, which is then inverted to give a default file-gamma value. But it is possible that the user has calibrated the display system more precisely and has defined the SCREEN_GAMMA environment variable as suggested by the libpng documentation. If so, this value is used instead. Note that the Macintosh code is incomplete. The Macintosh macro, presumed to be defined already, most likely would need to be set on the basis of compiler-specific macros. For example, the following preprocessor code would work for Metrowerks CodeWarrior and the Macintosh Programmer's Workbench, although MPW is not terribly specific and might be defined on non-Macintosh systems, too: #if !defined(Macintosh) # if defined(__MWERKS__) && defined(macintosh) # define Macintosh # elif defined(MPW) /* && defined(MCH_MACINTOSH) */ # define Macintosh # endif #endif In any case, the calculated file gamma is presented as part of wpng's
usage screen but thereafter ignored.
|
|
Home ![]() ![]() |