/usr/share/pyshared/glitch/PIL/imagecamera.py is in python-glitch 0.6-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | from __future__ import with_statement
"A camera that renders to an image file."
import Image
from glitch.camera import Camera
from glitch.read import Read
from glitch.fbo import BufferCamera
from glitch.glx import GLXContext
class ImageCamera(Camera):
"A camera that renders to an image file."
def __init__(self, width, height, out, *args, **kwargs):
self.out = out
Camera.__init__(self, *args, **kwargs)
self.context['w'] = width
self.context['h'] = height
self.context['frame'] = 0
self.glx_context = GLXContext()
def render(self, parent_ctx=None):
with self.glx_context:
read = Read(children=self.children)
bc = BufferCamera(
# XXX: Nicer way to pass values through?
eye=self.eye, ref=self.ref, up=self.up, fovy=self.fovy,
fovx=self.fovx, zNear=self.zNear, zFar=self.zFar,
clear=self.clear,
width=self.context['w'], height=self.context['h'],
children=[read])
bc.render(None)
im = Image.fromstring('RGB', (self.context['w'], self.context['h']),
read.get_pixbuf().get_pixels())
# XXX: Return the image somehow instead of saving it.
im.save(self.out % (self.context['frame']))
self.context['frame'] += 1
|