Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)