]> git.eshelyaron.com Git - emacs.git/commitdiff
(png_load): Set screen_gamma based on f->gamma.
authorRichard M. Stallman <rms@gnu.org>
Sun, 3 Mar 2002 20:07:42 +0000 (20:07 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 3 Mar 2002 20:07:42 +0000 (20:07 +0000)
If png_get_sRGB gives an answer, call png_set_gamma
using the default image gamma value.

src/xfns.c

index 748d8925a5351879d00f414d5ac3e7ffc7f4d8c2..8b7304025d7cbdc07db4e9008e0e0dd559a0182d 100644 (file)
@@ -9034,24 +9034,22 @@ png_load (f, img)
       || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
     png_set_gray_to_rgb (png_ptr);
 
-  /* The value 2.2 is a guess for PC monitors from PNG example.c.  */
-  gamma_str = getenv ("SCREEN_GAMMA");
-  screen_gamma = gamma_str ? atof (gamma_str) : 2.2;
+  screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2);
 
   /* Tell the PNG lib to handle gamma correction for us.  */
 
 #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
   if (png_get_sRGB (png_ptr, info_ptr, &intent))
-    /* There is a special chunk in the image specifying the gamma.  */
-    png_set_sRGB (png_ptr, info_ptr, intent);
+    /* The libpng documentation says this is right in this case.  */
+    png_set_gamma (png_ptr, screen_gamma, 0.45455);
   else
 #endif
   if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
     /* Image contains gamma information.  */
     png_set_gamma (png_ptr, screen_gamma, image_gamma);
   else
-    /* Use a default of 0.5 for the image gamma.  */
-    png_set_gamma (png_ptr, screen_gamma, 0.5);
+    /* Use the standard default for the image gamma.  */
+    png_set_gamma (png_ptr, screen_gamma, 0.45455);
 
   /* Handle alpha channel by combining the image with a background
      color.  Do this only if a real alpha channel is supplied.  For