From 67c62d8c9e650f594e9aea348b8ed0c1351c7d81 Mon Sep 17 00:00:00 2001 From: rcoh Date: Thu, 17 Feb 2011 02:45:27 -0500 Subject: Added JPGInput to process images. Modified Input and LightInstallation to support passing multiple inputs simultaeneously. Added FadeIn Pixel event. Needs work / configurability. --- inputs/JPGInput.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 inputs/JPGInput.py (limited to 'inputs') diff --git a/inputs/JPGInput.py b/inputs/JPGInput.py new file mode 100644 index 0000000..fd58a47 --- /dev/null +++ b/inputs/JPGInput.py @@ -0,0 +1,33 @@ +from operationscore.Input import * +from PIL import Image +import util.ComponentRegistry as compReg +import os +class JPGInput(Input): + def inputInit(self): + self.images = [] + self.imageIndex = 0 + compReg.getLock().acquire() + minX,minY,maxX,maxY = compReg.getComponent('Screen').getSize() + compReg.getLock().release() + sWidth = maxX-minX + sHeight = maxY-minY + for filename in os.listdir(self['Directory']): + path = os.path.join(self['Directory'], filename) + if '.jpg' in path or '.bmp' in path: + im = Image.open(path) #file to open + (w,h)=im.size + print w,h + xScale = sWidth/float(w) + yScale = sHeight/float(h) + pixels = [] + for x in range(w): + for y in range(h): + rgb = im.getpixel((x,y)) + pixels.append({'Location':(x*xScale+minX,minY+y*yScale),'Color':rgb}) + + self.images.append(pixels) + + def sensingLoop(self): + self.imageIndex += 1 + self.imageIndex = self.imageIndex % len(self.images) + self.respond(self.images[self.imageIndex]) -- cgit v1.2.3