aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2008-07-07 09:31:49 +0000
committerYAMAMOTO Mitsuharu2008-07-07 09:31:49 +0000
commit7321dc0ca850eedb19ac0d431c9a17301449bc97 (patch)
tree798e97b530f9504934542d254f8399561d4cde04
parent5922fd0ee09f51cfc4f3aa160d9bd4a7b23493e4 (diff)
downloademacs-7321dc0ca850eedb19ac0d431c9a17301449bc97.tar.gz
emacs-7321dc0ca850eedb19ac0d431c9a17301449bc97.zip
(png_load): Use correct bit-depth for setting background color.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/image.c48
2 files changed, 14 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d7826d013aa..0a9f3ec9a67 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12008-07-07 Chong Yidong <cyd@stupidchicken.com>
2
3 * image.c (png_load): Use correct bit-depth for setting background
4 color.
5
12008-05-15 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 62008-05-15 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2 7
3 * macterm.c (x_draw_relief_rect): Remove unused variable `dpy'. 8 * macterm.c (x_draw_relief_rect): Remove unused variable `dpy'.
diff --git a/src/image.c b/src/image.c
index 9981b21365a..f2dc1ae30ca 100644
--- a/src/image.c
+++ b/src/image.c
@@ -6517,7 +6517,6 @@ png_load (f, img)
6517 png_byte channels; 6517 png_byte channels;
6518 png_uint_32 row_bytes; 6518 png_uint_32 row_bytes;
6519 int transparent_p; 6519 int transparent_p;
6520 double screen_gamma;
6521 struct png_memory_storage tbr; /* Data to be read */ 6520 struct png_memory_storage tbr; /* Data to be read */
6522 6521
6523 /* Find out what file to load. */ 6522 /* Find out what file to load. */
@@ -6659,27 +6658,6 @@ png_load (f, img)
6659 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 6658 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
6660 fn_png_set_gray_to_rgb (png_ptr); 6659 fn_png_set_gray_to_rgb (png_ptr);
6661 6660
6662 screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2);
6663
6664#if 0 /* Avoid double gamma correction for PNG images. */
6665 { /* Tell the PNG lib to handle gamma correction for us. */
6666 int intent;
6667 double image_gamma;
6668#if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
6669 if (png_get_sRGB (png_ptr, info_ptr, &intent))
6670 /* The libpng documentation says this is right in this case. */
6671 png_set_gamma (png_ptr, screen_gamma, 0.45455);
6672 else
6673#endif
6674 if (png_get_gAMA (png_ptr, info_ptr, &image_gamma))
6675 /* Image contains gamma information. */
6676 png_set_gamma (png_ptr, screen_gamma, image_gamma);
6677 else
6678 /* Use the standard default for the image gamma. */
6679 png_set_gamma (png_ptr, screen_gamma, 0.45455);
6680 }
6681#endif /* if 0 */
6682
6683 /* Handle alpha channel by combining the image with a background 6661 /* Handle alpha channel by combining the image with a background
6684 color. Do this only if a real alpha channel is supplied. For 6662 color. Do this only if a real alpha channel is supplied. For
6685 simple transparency, we prefer a clipping mask. */ 6663 simple transparency, we prefer a clipping mask. */
@@ -6688,6 +6666,7 @@ png_load (f, img)
6688 png_color_16 *image_bg; 6666 png_color_16 *image_bg;
6689 Lisp_Object specified_bg 6667 Lisp_Object specified_bg
6690 = image_spec_value (img->spec, QCbackground, NULL); 6668 = image_spec_value (img->spec, QCbackground, NULL);
6669 int shift = (bit_depth == 16) ? 0 : 8;
6691 6670
6692 if (STRINGP (specified_bg)) 6671 if (STRINGP (specified_bg))
6693 /* The user specified `:background', use that. */ 6672 /* The user specified `:background', use that. */
@@ -6699,27 +6678,18 @@ png_load (f, img)
6699 png_color_16 user_bg; 6678 png_color_16 user_bg;
6700 6679
6701 bzero (&user_bg, sizeof user_bg); 6680 bzero (&user_bg, sizeof user_bg);
6702 user_bg.red = color.red >> 8; 6681 user_bg.red = color.red >> shift;
6703 user_bg.green = color.green >> 8; 6682 user_bg.green = color.green >> shift;
6704 user_bg.blue = color.blue >> 8; 6683 user_bg.blue = color.blue >> shift;
6705 6684
6706 fn_png_set_background (png_ptr, &user_bg, 6685 fn_png_set_background (png_ptr, &user_bg,
6707 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); 6686 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
6708 } 6687 }
6709 } 6688 }
6710 /* The commented-out code checked if the png specifies a default
6711 background color, and uses that. Since we use the current
6712 frame background, it is OK for us to ignore this.
6713
6714 else if (fn_png_get_bKGD (png_ptr, info_ptr, &image_bg))
6715 fn_png_set_background (png_ptr, image_bg,
6716 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
6717 */
6718 else 6689 else
6719 { 6690 {
6720 /* Image does not contain a background color with which 6691 /* We use the current frame background, ignoring any default
6721 to combine the image data via an alpha channel. Use 6692 background color set by the image. */
6722 the frame's background instead. */
6723#ifdef HAVE_X_WINDOWS 6693#ifdef HAVE_X_WINDOWS
6724 XColor color; 6694 XColor color;
6725 png_color_16 frame_background; 6695 png_color_16 frame_background;
@@ -6728,9 +6698,9 @@ png_load (f, img)
6728 x_query_color (f, &color); 6698 x_query_color (f, &color);
6729 6699
6730 bzero (&frame_background, sizeof frame_background); 6700 bzero (&frame_background, sizeof frame_background);
6731 frame_background.red = color.red >> 8; 6701 frame_background.red = color.red >> shift;
6732 frame_background.green = color.green >> 8; 6702 frame_background.green = color.green >> shift;
6733 frame_background.blue = color.blue >> 8; 6703 frame_background.blue = color.blue >> shift;
6734#endif /* HAVE_X_WINDOWS */ 6704#endif /* HAVE_X_WINDOWS */
6735 6705
6736#ifdef HAVE_NTGUI 6706#ifdef HAVE_NTGUI