[poppler] poppler/glib: poppler-page.cc,1.26,1.27

Kristian Hogsberg krh at freedesktop.org
Fri Jul 8 14:59:43 EST 2005


Update of /cvs/poppler/poppler/glib
In directory gabe:/tmp/cvs-serv22526/glib

Modified Files:
	poppler-page.cc 
Log Message:
2005-07-08  Kristian Høgsberg  <krh at redhat.com>

        * glib/poppler-page.cc (poppler_page_set_selection_alpha): Add
        this function to initialize the alpha channel when using the
        splash backend.

        * poppler/TextOutputDev.cc (visitLine): Add missing scaling of
        intra-line selection edges.



Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- poppler-page.cc	7 Jul 2005 17:19:38 -0000	1.26
+++ poppler-page.cc	8 Jul 2005 04:59:41 -0000	1.27
@@ -259,7 +259,7 @@
 }
 
 #elif defined (HAVE_SPLASH)
-
+ 
 typedef struct {
 } OutputDevData;
 
@@ -314,6 +314,8 @@
 	  dst[0] = splashRGB8R(*src);
 	  dst[1] = splashRGB8G(*src); 
 	  dst[2] = splashRGB8B(*src);
+	  if (pixbuf_n_channels == 4)
+	    dst[3] = 0;
 	  dst += pixbuf_n_channels;
 	  src++;
 	}
@@ -423,6 +425,59 @@
   return region;
 }
 
+#if defined (HAVE_CAIRO)
+
+static void
+poppler_page_set_selection_alpha (PopplerPage      *page,
+				  double            scale,
+				  GdkPixbuf        *pixbuf,
+				  PopplerRectangle *selection)
+{
+  /* Cairo doesn't need this, since cairo generates an alpha channel. */ 
+}
+
+#elif defined (HAVE_SPLASH)
+
+static void
+poppler_page_set_selection_alpha (PopplerPage      *page,
+				  double            scale,
+				  GdkPixbuf        *pixbuf,
+				  PopplerRectangle *selection)
+{
+  GdkRegion *region;
+  gint n_rectangles, i, x, y;
+  GdkRectangle *rectangles;
+  int pixbuf_rowstride, pixbuf_n_channels;
+  guchar *pixbuf_data, *dst;
+
+  pixbuf_data = gdk_pixbuf_get_pixels (pixbuf);
+  pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+  pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+
+  if (pixbuf_n_channels != 4)
+    return;
+
+  region = poppler_page_get_selection_region (page, scale, selection);
+
+  gdk_region_get_rectangles (region, &rectangles, &n_rectangles);
+  for (i = 0; i < n_rectangles; i++) {
+    for (y = 0; y < rectangles[i].height; y++) {
+      dst = pixbuf_data + (rectangles[i].y + y) * pixbuf_rowstride +
+	rectangles[i].x * pixbuf_n_channels;
+      for (x = 0; x < rectangles[i].width; x++) {
+	  dst[3] = 0xff;
+	  dst += pixbuf_n_channels;
+      }
+    }
+  }
+
+  g_free (rectangles);
+
+  gdk_region_destroy (region);
+}
+
+#endif
+
 void
 poppler_page_render_selection (PopplerPage *page,
 			       gdouble      scale,
@@ -445,6 +500,8 @@
 
   poppler_page_copy_to_pixbuf (page, pixbuf, &data);
 
+  poppler_page_set_selection_alpha (page, scale, pixbuf, selection);
+
   /* We'll need a function to destroy page->text_dev and page->gfx
    * when the application wants to get rid of them.
    *



More information about the poppler mailing list