/usr/share/pyshared/glitch/PIL/image.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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | "PIL image texture."
import PIL.Image
from glitch.texture import Texture
class ImageTexture(Texture):
"PIL image texture."
def __init__(self, image):
(width, height) = image.size
if image.mode == 'RGBA':
data = image.tostring("raw", "RGBA", 0, -1)
elif image.mode == 'RGBX' or image.mode == 'RGB':
data = image.tostring("raw", "RGBX", 0, -1)
else:
raise ValueError
Texture.__init__(self, width, height, data)
@classmethod
def from_file(cls, path):
return cls(PIL.Image.open(path))
def set_from_image(self, image):
(self.width, self.height) = image.size
self.data = image.tostring("raw", "RGBX", 0, -1)
def load_file(self, path):
image = PIL.Image.open(path)
self.set_from_image(image)
class ImageSequenceTexture(ImageTexture):
"""A sequence of images.
When rendered, this loads the current image based on the context value
C{frame}.
"""
def __init__(self, pattern):
"""pattern should be in the form `image-%06d.jpg' to refer to
a sequence of images like image-000001.jpg"""
self.pattern = pattern
self.version = 1
self.load_file(pattern % (1)) # XXX avoid forced initialization?
def upload(self, ctx):
self.load_file(self.pattern % (ctx['frame']))
ImageTexture.upload(self, ctx)
def update(self, ctx):
self.version = ctx['frame']
ImageTexture.update(self, ctx)
|