All pastes #718408 Raw Edit

Miscellany

public text v1 · immutable
#718408 ·published 2007-09-28 12:06 UTC
rendered paste body
import time

import gtk

window = gtk.gdk.screen_get_default().get_root_window()
width, height = window.get_size()

t = time.time()

pixmap = gtk.gdk.Pixmap(window, width, height)
pixmap.draw_drawable(window.new_gc(), window, 0, 0, 0, 0, width, height)

screenshot = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, has_alpha=False,
                            bits_per_sample=8, width=width, height=height)
screenshot.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0,
                                width, height)
print time.time() - t

screenshot.save('/tmp/screenshot.png', 'png')