aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman2002-03-03 20:07:42 +0000
committerRichard M. Stallman2002-03-03 20:07:42 +0000
commitd4405ed75180e10ebd5440ca65880d427edfa20d (patch)
tree3e1ff0f60dea6554ec01741aee707b085e082d4c /src
parent81a268b48ca7990868f4f75589789afcff29c077 (diff)
downloademacs-d4405ed75180e10ebd5440ca65880d427edfa20d.tar.gz
emacs-d4405ed75180e10ebd5440ca65880d427edfa20d.zip
(png_load): Set screen_gamma based on f->gamma.
If png_get_sRGB gives an answer, call png_set_gamma using the default image gamma value.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 748d8925a53..8b7304025d7 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -9034,24 +9034,22 @@ png_load (f, img)
9034 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 9034 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
9035 png_set_gray_to_rgb (png_ptr); 9035 png_set_gray_to_rgb (png_ptr);
9036 9036
9037 /* The value 2.2 is a guess for PC monitors from PNG example.c. */ 9037 screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2);
9038 gamma_str = getenv ("SCREEN_GAMMA");
9039 screen_gamma = gamma_str ? atof (gamma_str) : 2.2;
9040 9038
9041 /* Tell the PNG lib to handle gamma correction for us. */ 9039 /* Tell the PNG lib to handle gamma correction for us. */
9042 9040
9043#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED) 9041#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
9044 if (png_get_sRGB (png_ptr, info_ptr, &intent)) 9042 if (png_get_sRGB (png_ptr, info_ptr, &intent))
9045 /* There is a special chunk in the image specifying the gamma. */ 9043 /* The libpng documentation says this is right in this case. */
9046 png_set_sRGB (png_ptr, info_ptr, intent); 9044 png_set_gamma (png_ptr, screen_gamma, 0.45455);
9047 else 9045 else
9048#endif 9046#endif
9049 if (png_get_gAMA (png_ptr, info_ptr, &image_gamma)) 9047 if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
9050 /* Image contains gamma information. */ 9048 /* Image contains gamma information. */
9051 png_set_gamma (png_ptr, screen_gamma, image_gamma); 9049 png_set_gamma (png_ptr, screen_gamma, image_gamma);
9052 else 9050 else
9053 /* Use a default of 0.5 for the image gamma. */ 9051 /* Use the standard default for the image gamma. */
9054 png_set_gamma (png_ptr, screen_gamma, 0.5); 9052 png_set_gamma (png_ptr, screen_gamma, 0.45455);
9055 9053
9056 /* Handle alpha channel by combining the image with a background 9054 /* Handle alpha channel by combining the image with a background
9057 color. Do this only if a real alpha channel is supplied. For 9055 color. Do this only if a real alpha channel is supplied. For