libgnomeprint r2292 - in trunk: . libgnomeprint
- From: kmaraas svn gnome org
- To: svn-commits-list gnome org
- Subject: libgnomeprint r2292 - in trunk: . libgnomeprint
- Date: Sat, 2 Feb 2008 19:31:35 +0000 (GMT)
Author: kmaraas
Date: Sat Feb 2 19:31:34 2008
New Revision: 2292
URL: http://svn.gnome.org/viewvc/libgnomeprint?rev=2292&view=rev
Log:
2008-02-02 Kjartan Maraas <kmaraas gnome org>
* NEWS: Update.
* libgnomeprint/gnome-print-ps2.c: (gnome_print_ps2_image):
Patch from Behdad Esfahbod to fix graphics being printed as
black squares. Closes bug #513699.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/libgnomeprint/gnome-print-ps2.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sat Feb 2 19:31:34 2008
@@ -1,3 +1,8 @@
+libgnomeprint 2.18.4
+
+ * Support searching and cut'n'paste of text in PDF files
+ output by libgnomeprint. (Suresh Chandrasekharan)
+
libgnomeprint 2.18.3
* Fix use of uninitialized variable (Coverity)
Modified: trunk/libgnomeprint/gnome-print-ps2.c
==============================================================================
--- trunk/libgnomeprint/gnome-print-ps2.c (original)
+++ trunk/libgnomeprint/gnome-print-ps2.c Sat Feb 2 19:31:34 2008
@@ -367,7 +367,8 @@
{
GnomePrintPs2 *ps2 = GNOME_PRINT_PS2 (pc);
gchar *hex;
- gint hex_size, r;
+ guchar *row;
+ gint hex_size, r, out_ch;
gboolean problem;
problem = gnome_print_ps2_puts (ps2, "q" EOL "[");
@@ -392,20 +393,70 @@
if (ch == 1) {
problem |= gnome_print_ps2_puts (ps2, "image" EOL);
} else {
- problem |= gnome_print_ps2_fprintf (ps2, "false %d colorimage" EOL, ch);
+ problem |= gnome_print_ps2_fprintf (ps2, "false 3 colorimage" EOL);
}
g_return_val_if_fail (!problem, GNOME_PRINT_ERROR_UNKNOWN);
- hex = g_new (gchar, gnome_print_encode_hex_wcs (w * ch));
+ out_ch = ch;
+ if (ch == 4) {
+ /* Postscript doesn't support alpha channel. The 4-channel
+ * colorimage operator takes CMYK, not RGBA!
+ * We flatten image against white background in the loop.
+ */
+ out_ch = 3;
+ row = g_new (guchar, w * out_ch);
+ }
+
+ hex = g_new (gchar, gnome_print_encode_hex_wcs (w * out_ch));
for (r = 0; r < h; r++) {
- hex_size = gnome_print_encode_hex (px + r * rowstride, (guchar *) hex, w * ch);
+ if (out_ch == ch) {
+ row = px + r * rowstride;
+ } else {
+ const guchar *p = px + r * rowstride;
+ guchar *q = row;
+ int i;
+
+ /* Flatten.
+ * Blend against white background is:
+ * new_color = color * alpha + (1 - alpha)
+ * With 8-bit data that is:
+ * new_color = color * alpha / 255 + (255 - alpha)
+ */
+ for (i = 0; i < w; i++) {
+ unsigned int alpha = p[3];
+ unsigned int one_minus_alpha = 255 - alpha;
+
+ /* special case common cases */
+ if (alpha == 255) {
+ *q++ = *p++;
+ *q++ = *p++;
+ *q++ = *p++;
+ p++; /* skip alpha */
+ } else if (alpha == 0) {
+ *q++ = 255;
+ *q++ = 255;
+ *q++ = 255;
+ p += 4;
+ } else {
+ *q++ = (*p++ * alpha) / 255 + one_minus_alpha;
+ *q++ = (*p++ * alpha) / 255 + one_minus_alpha;
+ *q++ = (*p++ * alpha) / 255 + one_minus_alpha;
+ p++; /* skip alpha */
+ }
+ }
+ }
+
+ hex_size = gnome_print_encode_hex (row, (guchar *) hex, w * out_ch);
problem |= fwrite (hex, sizeof (gchar), hex_size, ps2->buf);
problem |= gnome_print_ps2_puts (ps2, EOL);
}
g_free (hex);
+ if (out_ch != ch)
+ g_free (row);
+
problem |= gnome_print_ps2_puts (ps2, "Q" EOL);
return problem ? GNOME_PRINT_ERROR_UNKNOWN : GNOME_PRINT_OK;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]