예제 #1
0
파일: recordvideo.py 프로젝트: aidanok/kivy
def window_flip_and_save():
    global dump_idx
    win = kivy.getWindow()
    glReadBuffer(GL_FRONT)
    data = glReadPixels(0, 0, win.width, win.height, GL_RGB, GL_UNSIGNED_BYTE)
    surface = pygame.image.fromstring(str(buffer(data)), win.size, 'RGB', True)
    filename = '%s%05d.%s' % (dump_prefix, dump_idx, dump_format)
    pygame.image.save(surface, filename)
    dump_idx += 1
예제 #2
0
파일: mjpegserver.py 프로젝트: aidanok/kivy
def window_flip_and_save():
    global img_current
    win = kivy.getWindow()

    with lock_current:
        if not connected:
            return

    sem_next.acquire()

    with lock_current:
        glReadBuffer(GL_FRONT)
        data = glReadPixels(0, 0, win.width, win.height, GL_RGB,
                            GL_UNSIGNED_BYTE)
        img_current = str(buffer(data))

    sem_current.release()
예제 #3
0
파일: keybinding.py 프로젝트: arasbm/kivy
def _screenshot():
    import os
    import pygame
    from kivy.core.gl import glReadBuffer, glReadPixels, GL_RGB, \
                             GL_UNSIGNED_BYTE, GL_FRONT
    win = getWindow()
    glReadBuffer(GL_FRONT)
    data = glReadPixels(0, 0, win.width, win.height, GL_RGB, GL_UNSIGNED_BYTE)
    surface = pygame.image.fromstring(str(buffer(data)), win.size, 'RGB', True)
    filename = None
    for i in xrange(9999):
        path = os.path.join(os.getcwd(), 'screenshot%04d.jpg' % i)
        if not os.path.exists(path):
            filename = path
            break
    if filename:
        try:
            pygame.image.save(surface, filename)
            Logger.info('KeyBinding: Screenshot saved at %s' % filename)
        except:
            Logger.exception('KeyBinding: Unable to take a screenshot')
    else:
        warn = 'KeyBinding: Unable to take screenshot, no more slot available'
        Logger.warning(warn)