add 2D image support

master
Raphaël Vinot 2015-03-05 23:37:16 +01:00
parent fd4089dae9
commit c1c24bdf3b
2 changed files with 6 additions and 6 deletions

View File

@ -6,9 +6,8 @@ import jarray
gamma = 1.7 gamma = 1.7
framerate = 0.0 framerate = 0.0
brightness = 4 brightness = 12
errorCount = 0 errorCount = 0
gammatable = [0 for i in range(0, 256)]
s = None s = None
img = None img = None
ledSerial = None ledSerial = None
@ -26,11 +25,12 @@ def setup():
gammatable = [math.pow(i / 255.0, gamma) * 255.0 + 0.5 for i in range(0, 256)] gammatable = [math.pow(i / 255.0, gamma) * 255.0 + 0.5 for i in range(0, 256)]
size(40, 1) size(40, 1)
img = loadImage("test2.png") img = loadImage("test3.png")
def image2data(data): def image2data(data):
offset = 0 offset = 3
for x in range(0, img.width): dimension = img.width * img.height
for x in xrange(0, dimension, 1):
pixel = [colorWiring(img.pixels[x]) for i in range(0, 8)] pixel = [colorWiring(img.pixels[x]) for i in range(0, 8)]
imgmask = 0x800000 imgmask = 0x800000
while imgmask != 0: while imgmask != 0:
@ -85,7 +85,7 @@ def serialConfigure(portName):
def draw(): def draw():
global img global img
image(img, 0, 0) image(img, 0, 0)
data = jarray.zeros(img.width * 24 + 3, "b") data = jarray.zeros(img.width * img.height * 24 + 3, "b")
image2data(data) image2data(data)
data[0] = ord('*') data[0] = ord('*')
framerate = 30.0 framerate = 30.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B