def get_screenshot():
    """makes screenshot of the current root window, yields Gtk.Pixbuf"""
    pixbuf = get_screenshot_as_pixbuffer()

    b = StringIO()
    pixbuf.save_to_callback(b.write, 'png', [], ["100"])
    return b.getvalue()    
示例#2
0
def get_screenshot():
    """makes screenshot of the current root window, yields Gtk.Pixbuf"""
    pixbuf = get_screenshot_as_pixbuffer()

    b = StringIO()
    pixbuf.save_to_callback(b.write, 'png', [], ["100"])
    return b.getvalue()
示例#3
0
def screen():
    response.content_type = 'image/png'
    pb = get_screenshot_as_pixbuffer()
    ifile = tempfile.NamedTemporaryFile(suffix='.png')
    pb.savev(ifile.name, "png", [], ["100"])
    pb= open(ifile.name, 'r')
    if pb:
        return pb
    else:
        return "Error"
示例#4
0
    def test_screenshot(self):
        pb = miscellaneous.get_screenshot_as_pixbuffer()
        ifile = tempfile.NamedTemporaryFile(suffix='.png')
        pb.savev(ifile.name, "png", [], ["100"])
        imagefile = open(ifile.name, 'r')
        self.assertIsNotNone(imagefile)

        # TODO: use https://github.com/ahupp/python-magic ??
        # Check 1
        url = urllib.pathname2url(imagefile.name)
        self.assertEqual(mimetypes.guess_type(url)[0], 'image/png')
        # Check 2
        mimeType = subprocess.check_output(['file', '-ib', imagefile.name]).strip()
        self.assertTrue('image/png' in mimeType)