Created
September 3, 2011 00:53
-
-
Save adambard/1190312 to your computer and use it in GitHub Desktop.
DDBot: Take Screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def take_screenshot(): | |
""" | |
Use GTK to get a screengrab of the current screen. | |
Returns an (x, y, 3) full-color pixel array | |
""" | |
w = gtk.gdk.get_default_root_window() | |
sz = w.get_size() | |
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1]) | |
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1]) | |
return pb.get_pixels_array() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment