summaryrefslogtreecommitdiff
blob: 98bc637241fcf9f12eb8d9e4832d92b5d368aff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Stop using render_to_pixbuf, removed from Poppler 0.18.

Instead draw to a gdk Pixmap, then get a Pixbuf from that.

A more complete fix (dropping Pixmap/Pixbuf usage) is in upstream svn,
but that is too large a change for us to take.

Based on a patch from Rafał Mużyło in gentoo bug #390607.
--- pdfshuffler
+++ pdfshuffler
@@ -982,9 +982,15 @@
             pix_w, pix_h = page.get_size()
             pix_w = int(pix_w * self.scale)
             pix_h = int(pix_h * self.scale)
-            thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
-                                       8, pix_w , pix_h)
-            page.render_to_pixbuf(0,0,pix_w,pix_h,self.scale,0,thumbnail)
+            pixmap = gtk.gdk.Pixmap(None, pix_w, pix_h, 24)
+            cr = pixmap.cairo_create()
+            # The pixmap data is not initialized, so paint it white first:
+            cr.set_source_rgb(1, 1, 1)
+            cr.paint()
+            cr.scale(self.scale, self.scale)
+            page.render(cr)
+            thumbnail = gtk.gdk.pixbuf_get_from_drawable(
+                None, pixmap, gtk.gdk.colormap_get_system(), 0, 0, 0, 0, pix_w, pix_h)
             rotation = (-rotation) % 360
             rotation = ((rotation + 45) / 90) * 90
             thumbnail = thumbnail.rotate_simple(rotation)
@@ -1003,11 +1009,13 @@
                 pix_w = thumbnail.get_width()
                 pix_h = thumbnail.get_height()
         except:
+            import traceback
+            traceback.print_exc()
             pix_w = self.default_width
             pix_h = pix_w
             thumbnail = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False,
                                        8, pix_w, pix_h)
-            pixbuf.fill(0xffffffff)
+            thumbnail.fill(0xffffffff)
 
         #add border
         thickness = 3