#!/usr/local/bin/python
"otb Nokia OTA Bitmap "
"""
+00 0x30
+01 0x00
+02 0x00
+03 length of message
+04 message...
"""
def tobits(x):
s = []
for b in range(8):
s += [ [ 0, 1 ][x&1] ]
x >>= 1
s.reverse()
return s
import sys, struct
fp = open(sys.argv[1])
x, y, z, msglen = struct.unpack('BBBB', fp.read(4))
message = fp.read(msglen)
print "Message:", message
print struct.unpack('BBB', fp.read(3))
icons, width, height, bpp = struct.unpack('BBBB', fp.read(4))
bits = []
while 1:
c = fp.read(1)
if not c:
break
bits += tobits(ord(c))
size = ( width, height )
step = 0
print len(bits), len(bits) / size[1], size[0] * size[1]
def render(bits):
global size, step
print "Using", size, "and", step
for y in range(size[1]):
for x in range(size[0]):
try:
sys.stdout.write([ ' ', 'X' ][bits[step + y*size[0] + x]])
except:
sys.stdout.write('!')
sys.stdout.write('.\n')
render(bits)
while 1:
cmd = raw_input('cmd:')
if cmd == 'd':
size = input('size:')
elif cmd == 's':
step = int(raw_input('step:'))
render(bits)