Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@cscott.net>2011-11-11 04:32:49 (GMT)
committer C. Scott Ananian <cscott@cscott.net>2011-11-11 04:32:49 (GMT)
commit99a822387bd489a855aa4e854034313c59a43f4c (patch)
tree3f843fb1bc494da7cb94a0c013a792d990b64362
parentb12bba9b4af86a39130665cc1542a8b1c67e94f5 (diff)
Workaround: GdkPixbuf.get_pixels() does not have a functional GIR binding.
We use a new cairo.ImageSurface instead; ImageSurface.get_data() returns a properly wrapped python buffer object.
-rw-r--r--TurtleArt/tacanvas.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py
index 8b294a9..7a31b90 100644
--- a/TurtleArt/tacanvas.py
+++ b/TurtleArt/tacanvas.py
@@ -700,11 +700,16 @@ class TurtleGraphics:
h = self.tw.turtle_canvas.get_height()
if x < 0 or x > (w - 1) or y < 0 or y > (h - 1):
return(-1, -1, -1, -1)
- # Map the cairo surface onto a pixbuf
- pixbuf = Gdk.pixbuf_get_from_surface(self.tw.turtle_canvas,
- x, y, 1, 1)
+ # create a new 1x1 cairo surface
+ cs = cairo.ImageSurface(cairo.FORMAT_RGB24, 1, 1);
+ cr = cairo.Context(cs)
+ cr.set_source_surface(self.tw.turtle_canvas, -x, -y)
+ cr.rectangle(0,0,1,1)
+ cr.set_operator(cairo.OPERATOR_SOURCE)
+ cr.fill()
+ cs.flush() # ensure all writing is done
# Read the pixel
- pixels = pixbuf.get_pixels()
+ pixels = cs.get_data()
return (ord(pixels[0]), ord(pixels[1]), ord(pixels[2]), 0)
else:
return(-1, -1, -1, -1)