Ejemplo n.º 1
0
def show(file):
    import gl, GL, DEVICE
    jpegdata = open(file, 'r').read()
    imgdata, width, height, bytesperpixel = decompress(jpegdata)
    gl.foreground()
    gl.prefsize(width, height)
    win = gl.winopen(file)
    if bytesperpixel == 1:
        gl.cmode()
        gl.pixmode(GL.PM_SIZE, 8)
        gl.gconfig()
        for i in range(256):
            gl.mapcolor(i, i, i, i)

    else:
        gl.RGBmode()
        gl.pixmode(GL.PM_SIZE, 32)
        gl.gconfig()
    gl.qdevice(DEVICE.REDRAW)
    gl.qdevice(DEVICE.ESCKEY)
    gl.qdevice(DEVICE.WINQUIT)
    gl.qdevice(DEVICE.WINSHUT)
    gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)
    while 1:
        dev, val = gl.qread()
        if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
            break
        if dev == DEVICE.REDRAW:
            gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)

    gl.winclose(win)
    newjpegdata = compress(imgdata, width, height, bytesperpixel)
    open('/tmp/j.jpg', 'w').write(newjpegdata)
Ejemplo n.º 2
0
def show(file):
    import gl, GL, DEVICE
    jpegdata = open(file, 'r').read()
    imgdata, width, height, bytesperpixel = decompress(jpegdata)
    gl.foreground()
    gl.prefsize(width, height)
    win = gl.winopen(file)
    if bytesperpixel == 1:
        gl.cmode()
        gl.pixmode(GL.PM_SIZE, 8)
        gl.gconfig()
        for i in range(256):
            gl.mapcolor(i, i, i, i)

    else:
        gl.RGBmode()
        gl.pixmode(GL.PM_SIZE, 32)
        gl.gconfig()
    gl.qdevice(DEVICE.REDRAW)
    gl.qdevice(DEVICE.ESCKEY)
    gl.qdevice(DEVICE.WINQUIT)
    gl.qdevice(DEVICE.WINSHUT)
    gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)
    while 1:
        dev, val = gl.qread()
        if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
            break
        if dev == DEVICE.REDRAW:
            gl.lrectwrite(0, 0, width - 1, height - 1, imgdata)

    gl.winclose(win)
    newjpegdata = compress(imgdata, width, height, bytesperpixel)
    open('/tmp/j.jpg', 'w').write(newjpegdata)
Ejemplo n.º 3
0
def grab_rgb8(w, h, pf):
    if gl.getdisplaymode() <> GET.DMRGB:
        raise Error, 'Sorry, can only grab rgb8 in single-buf rgbmode'
    if pf <> (1, 1):
        raise Error, 'Sorry, can only grab rgb8 with packfactor (1,1)'
    if not VFile.is_entry_indigo():
        raise Error, 'Sorry, can only grab rgb8 on entry level Indigo'
    # XXX Dirty Dirty here.
    # XXX Set buffer to cmap mode, grab image and set it back.
    gl.cmode()
    gl.gconfig()
    gl.pixmode(GL.PM_SIZE, 8)
    data = gl.lrectread(0, 0, w - 1, h - 1)
    data = data[:w * h]  # BUG FIX for python lrectread
    gl.RGBmode()
    gl.gconfig()
    gl.pixmode(GL.PM_SIZE, 32)
    return data, None
Ejemplo n.º 4
0
def grab_rgb8(w, h, pf):
	if gl.getdisplaymode() <> GET.DMRGB:
		raise Error, 'Sorry, can only grab rgb8 in single-buf rgbmode'
	if pf <> (1, 1):
		raise Error, 'Sorry, can only grab rgb8 with packfactor (1,1)'
	if not VFile.is_entry_indigo():
		raise Error, 'Sorry, can only grab rgb8 on entry level Indigo'
	# XXX Dirty Dirty here.
	# XXX Set buffer to cmap mode, grab image and set it back.
	gl.cmode()
	gl.gconfig()
	gl.pixmode(GL.PM_SIZE, 8)
	data = gl.lrectread(0, 0, w-1, h-1)
	data = data[:w*h]	# BUG FIX for python lrectread
	gl.RGBmode()
	gl.gconfig()
	gl.pixmode(GL.PM_SIZE, 32)
	return data, None
Ejemplo n.º 5
0
# Implement 'jpeg' interface using SGI's compression library
Ejemplo n.º 6
0
	def set_cmode(self):
		gl.cmode()
		gl.gconfig()
Ejemplo n.º 7
0
 def set_cmode(self):
     gl.cmode()
     gl.gconfig()
Ejemplo n.º 8
0
# Classes to read and write CMIF video files.
Ejemplo n.º 9
0
# Class to grab frames from a window.
Ejemplo n.º 10
0
# Classes to read and write CMIF video files.