After a forced education into the wonders of specifiers and their care
and feeding in C, I think I've got this nailed. This fixes display
problems for Steve's beer-swilling penguin that he mailed earlier
today. Now the background for display is the same as the background
of the default face.
1998-07-29 P. E. Jareth Hein <jareth(a)camelot.co.jp>
* glyphs-eimage.c (png_instantiate): Add proper handling for background
colors taken from the default face. Also correct a thinko in transparency
(not alpha) handling.
Index: glyphs-eimage.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-20/src/glyphs-eimage.c,v
retrieving revision 1.3
diff -u -u -r1.3 glyphs-eimage.c
--- glyphs-eimage.c 1998/06/13 04:28:48 1.3
+++ glyphs-eimage.c 1998/07/29 21:05:10
@@ -49,6 +50,7 @@
#include "lstream.h"
#include "console.h"
#include "device.h"
+#include "faces.h"
#include "glyphs.h"
#include "objects.h"
@@ -902,6 +688,42 @@
for (y = 0; y < height; y++)
row_pointers[y] = unwind.eimage + (width * 3 * y);
+ {
+ /* if the png specifies a background chunk, go ahead and
+ use it, else use what we can get from the default face. */
+ png_color_16 my_background, *image_background;
+ Lisp_Object bkgd = Qnil;
+
+ my_background.red = 0x7fff;
+ my_background.green = 0x7fff;
+ my_background.blue = 0x7fff;
+ bkgd = FACE_BACKGROUND (Vdefault_face, domain);
+ if (!COLOR_INSTANCEP (bkgd))
+ {
+ warn_when_safe (Qpng, Qinfo, "Couldn't get background color!");
+ }
+ else
+ {
+ struct Lisp_Color_Instance *c;
+ Lisp_Object rgblist;
+
+ c = XCOLOR_INSTANCE (bkgd);
+ rgblist = MAYBE_LISP_DEVMETH (XDEVICE (c->device),
+ color_instance_rgb_components,
+ (c));
+ my_background.red = XINT (XCAR (rgblist));
+ my_background.green = XINT (XCAR (XCDR (rgblist)));
+ my_background.blue = XINT (XCAR (XCDR (XCDR (rgblist))));
+ }
+
+ if (png_get_bKGD (png_ptr, info_ptr, &image_background))
+ png_set_background (png_ptr, image_background,
+ PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
+ else
+ png_set_background (png_ptr, &my_background,
+ PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
+ }
+
/* Now that we're using EImage, ask for 8bit RGB triples for any type
of image*/
/* convert palatte images to full RGB */
@@ -914,12 +736,6 @@
/* we can't handle alpha values */
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
png_set_strip_alpha (png_ptr);
- /* rip out any transparancy layers/colors */
- if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
- {
- png_set_expand (png_ptr);
- png_set_strip_alpha (png_ptr);
- }
/* tell libpng to strip 16 bit depth files down to 8 bits */
if (info_ptr->bit_depth == 16)
png_set_strip_16 (png_ptr);
@@ -932,25 +748,6 @@
png_set_packing (png_ptr);
}
-#if 1 /* tests? or permanent? */
- {
- /* if the png specifies a background chunk, go ahead and
- use it */
- png_color_16 my_background, *image_background;
-
- /* ### how do I get the background of the current frame? */
- my_background.red = 0x7fff;
- my_background.green = 0x7fff;
- my_background.blue = 0x7fff;
-
- if (png_get_bKGD (png_ptr, info_ptr, &image_background))
- png_set_background (png_ptr, image_background,
- PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
- else
- png_set_background (png_ptr, &my_background,
- PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
- }
-#endif
png_read_image (png_ptr, row_pointers);
png_read_end (png_ptr, info_ptr);
--
Jareth Hein | jareth(a)camelot.co.jp | ハイン ジェラス
Toolsmith & Program lead |
http://www.camelot.co.jp | 開発部チーフ
Camelot Software, Ltd. | |(株)キャメロット
"It's a sad sign of the times when 'political machine' is redefined to
include 'main-line battle tank'" - Ambassador Grossblunder