+ {
+ /* 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);
+ }
+