changeset 121:045ac4c27e62

Fri Dec 1 14:27:55 2006 John Ellis <johne@verizon.net> * print.c (print_job_ps_page_image): Use a white mask when printing transparent images, fixes bug #1426596.
author gqview
date Fri, 01 Dec 2006 19:41:45 +0000
parents f0ecfb80be38
children e2a8b7f2165b
files ChangeLog TODO src/print.c
diffstat 3 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Nov 30 22:59:49 2006 +0000
+++ b/ChangeLog	Fri Dec 01 19:41:45 2006 +0000
@@ -1,3 +1,8 @@
+Fri Dec  1 14:27:55 2006  John Ellis  <johne@verizon.net>
+
+	* print.c (print_job_ps_page_image): Use a white mask when printing
+	transparent images, fixes bug #1426596.
+
 Thu Nov 30 09:55:42 2006  John Ellis  <johne@verizon.net>
 
 	* slideshow.c (real_slideshow_start): Fix memory leak when unable to
--- a/TODO	Thu Nov 30 22:59:49 2006 +0000
+++ b/TODO	Fri Dec 01 19:41:45 2006 +0000
@@ -131,7 +131,7 @@
 
  > do not lose slideshow when reworking window layout.
 
- > fix printing of transparent images to not use black for transparency (white or user settable).
+d> fix printing of transparent images to not use black for transparency (white or user settable).
 
  > fix comment field in keywords bar to a height of 2 or 3 text lines.
 
--- a/src/print.c	Thu Nov 30 22:59:49 2006 +0000
+++ b/src/print.c	Fri Dec 01 19:41:45 2006 +0000
@@ -67,6 +67,10 @@
 #define PRINT_PS_DPI_MIN 150.0
 /* method to use when scaling down image data */
 #define PRINT_PS_MAX_INTERP GDK_INTERP_BILINEAR
+/* color to use as mask when printing transparent images */
+#define PRINT_PS_MASK_R 255
+#define PRINT_PS_MASK_G 255
+#define PRINT_PS_MASK_B 255
 
 /* padding between objects */
 #define PRINT_TEXT_PADDING 3.0
@@ -1232,6 +1236,7 @@
 	gint i, j;
 	gint c;
 	guchar *p;
+	guchar bps_buf[3];
 	gint ret;
 
 	if (!pixbuf) return TRUE;
@@ -1280,7 +1285,17 @@
 		p = pix + j * rowstride;
 		for (i = 0; i < sw; i++)
 			{
-			print_job_ps_page_image_pixel(f, p);
+			if (bps == 3)
+				{
+				print_job_ps_page_image_pixel(f, p);
+				}
+			else
+				{
+				bps_buf[0] = (p[0] * p[3] + PRINT_PS_MASK_R * (256 - p[3])) >> 8;
+				bps_buf[1] = (p[1] * p[3] + PRINT_PS_MASK_G * (256 - p[3])) >> 8;
+				bps_buf[2] = (p[2] * p[3] + PRINT_PS_MASK_B * (256 - p[3])) >> 8;
+				print_job_ps_page_image_pixel(f, bps_buf);
+				}
 			p+=bps;
 			c++;
 			if (c > 11)