0

I am created an instance of gtk.gdk.Pixmap, and painted on it something. For example:

pixmap = gtk.gdk.Pixmap(widget.window,100,800)
pixmap.draw_rectangle(gc, True, 0, 0, 100, 800)
pixmap.draw_line(gc, 0, 0,100, 800)

How can I to resize the Pixmap? One way that I see is to copy the Pixmap into a PixBuf using gtk.gdk.Pixbuf.get_from_drawable, then resize the Pixbuf, and then copy the Pixbuf to the Pixmap

Is there any way to do this without all the copying?

Adam Wagner
  • 15,469
  • 7
  • 52
  • 66
Habibutsu
  • 592
  • 1
  • 8
  • 20

2 Answers2

1

Unfortunately it's not possible without all this copying. Please note that GdkPixmap and GdkPixbuf are deprecated in favor of Cairo.

plaes
  • 31,788
  • 11
  • 91
  • 89
1

Indeed, those are deprecated.

More importantly, GdkPixmap is a server-side resource - the contents of the pixmap live in the X server's memory. When you do get_from_drawable(), you are asking for those contents to be transferred to your application, which is expensive.

Instead, create a Cairo image suface, and do your drawing there. This is a client-side resource, so you won't get that performance penalty. Image surfaces can be scaled by drawing them to another surface with a suitable transformation.