From 99a822387bd489a855aa4e854034313c59a43f4c Mon Sep 17 00:00:00 2001 From: C. Scott Ananian Date: Fri, 11 Nov 2011 04:32:49 +0000 Subject: 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. --- 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) -- cgit v0.9.1