Skip to content

Commit

Permalink
First working prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsH committed Oct 27, 2016
0 parents commit afd2197
Show file tree
Hide file tree
Showing 6 changed files with 5,167 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
compress
uncompress
*.tmp
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all: compress uncompress

uncompress compress : miniz.c Makefile
gcc -DFUNCTION=mz_$@ -o $@ $<

Binary file added cargo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions decoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import qrtools, os


def openLevel(imagename):
qr = qrtools.QR()
assert(qr.decode('cargo.png'))
levelData = eval(repr(qr.data)[1:])

header = levelData[:4]
print 'Header:', header.encode('hex')

compressedData = levelData[4:]
f = open('in.tmp','w')
f.write(compressedData);
f.close()
assert(os.system('./uncompress %u < in.tmp > out.tmp'%len(compressedData)) == 0)
indata = open('out.tmp').read()
[l, data] = indata.split('\n',1)
l = int(l)
assert l == len(data)
nameLen = ord(data[0])
name = data[1:1+nameLen]
print repr(name)
authorLen = ord(data[1+nameLen]) + 1
author = data[2+nameLen:1+nameLen+authorLen]
print repr(author)

levelData = data[1+nameLen+authorLen:]
print hex(len(levelData))
return name, author, levelData

level = openLevel('cargo.png')
print level
Loading

0 comments on commit afd2197

Please sign in to comment.