Exemple #1
0
 def on_text(self, text):
     if text != 's': return pyglet.window.event.EVENT_UNHANDLED
     image = pyglet.image.BufferImage().get_raw_image()
     fn = filename + '.png'
     n = 1
     while os.path.exists(fn):
         fn = filename + str(n) + '.png'
         n += 1
     print "Saving to '%s'"%fn
     image.save(fn)
Exemple #2
0
def take_screenshot(window):
    """This is your registered on_key_press handler.

    window is the pyglet.window.Window object to grab.
    """
    gl.glPixelTransferf(gl.GL_ALPHA_BIAS, 1.0)  # don't transfer alpha channel
    image = pyglet.image.ColorBufferImage(0, 0, window.width, window.height)
    image.save(screenshot_path())
    gl.glPixelTransferf(gl.GL_ALPHA_BIAS,
                        0.0)  # restore alpha channel transfer
Exemple #3
0
def take_screenshot(window, path=None):
    """Take a screenshot of the given window.

    Save it to a new path returned by screenshot_path.

    """
    # disable transfer alpha channel
    gl.glPixelTransferf(gl.GL_ALPHA_BIAS, 1.0)
    image = pyglet.image.ColorBufferImage(0, 0, window.width, window.height)
    image.save(path or screenshot_path())
    # re-enable alpha channel transfer
    gl.glPixelTransferf(gl.GL_ALPHA_BIAS, 0.0)
Exemple #4
0
def _debug_image(image, name):
    filename = _debug_filename(name, 'png')
    image.save(filename)
    _debug('Saved image %r to %s' % (image, filename))
Exemple #5
0
def _debug_image(image, name):
    filename = _debug_filename(name, 'png')
    image.save(filename)
    _debug('Saved image %r to %s' % (image, filename))
Exemple #6
0
def _debug_image(image, name):
    filename = _debug_filename(name, "png")
    image.save(filename)
    _debug("Saved image %r to %s" % (image, filename))