diff options
author | C. Scott Ananian <cscott@cscott.net> | 2011-11-10 23:33:09 (GMT) |
---|---|---|
committer | C. Scott Ananian <cscott@cscott.net> | 2011-11-10 23:33:09 (GMT) |
commit | 79f5678feeb16910c27ac6c24e93ca0f8b479c8d (patch) | |
tree | 71e79afc594338dd56f1d2dea5737cf30e993272 /TurtleArt | |
parent | 5a01e94347c1cd78b0deb4fc64c649536ae6ac1f (diff) |
Fix 'read pixel' operation under GTK3 (now faster in GTK2 as well).
Diffstat (limited to 'TurtleArt')
-rw-r--r-- | TurtleArt/tacanvas.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py index ac20092..8b294a9 100644 --- a/TurtleArt/tacanvas.py +++ b/TurtleArt/tacanvas.py @@ -700,16 +700,12 @@ 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 pixmap - pixmap = gtk.gdk.Pixmap(None, w, h, 24) - cr = pixmap.cairo_create() - cr.set_source_surface(self.tw.turtle_canvas, 0, 0) - cr.paint() + # Map the cairo surface onto a pixbuf + pixbuf = Gdk.pixbuf_get_from_surface(self.tw.turtle_canvas, + x, y, 1, 1) # Read the pixel - pixel = pixmap.get_image(x, y, 1, 1).get_pixel(0, 0) - return(int((pixel & 0xFF0000) >> 16), - int((pixel & 0x00FF00) >> 8), - int((pixel & 0x0000FF) >> 0), 0) + pixels = pixbuf.get_pixels() + return (ord(pixels[0]), ord(pixels[1]), ord(pixels[2]), 0) else: return(-1, -1, -1, -1) |