tangstad/helds
tangstad
/
helds
Archived
1
0
Fork 0

Added some informational prints.

This commit is contained in:
Truls Alexander Tangstad 2005-11-09 20:46:28 +00:00
parent 1e69b994f3
commit f0e4020280
1 changed files with 2 additions and 1 deletions

View File

@ -22,6 +22,7 @@ if __name__=="__main__":
im = Image.open(sys.argv[1]) im = Image.open(sys.argv[1])
output = open(sys.argv[2], "wb") output = open(sys.argv[2], "wb")
width, height = im.size width, height = im.size
print "Converting %dx%d image to binary." % (width, height)
for y in range(height): for y in range(height):
for x in range(width): for x in range(width):
val = im.getpixel((x, y)) val = im.getpixel((x, y))
@ -29,9 +30,9 @@ if __name__=="__main__":
if len(sys.argv) > 3: if len(sys.argv) > 3:
pal_output = open(sys.argv[3], "wb") pal_output = open(sys.argv[3], "wb")
print "Converting %d color palette." % (len(im.palette.palette) / 3)
for color in split_seq(im.palette.palette, 3): for color in split_seq(im.palette.palette, 3):
r, g, b = map(lambda col : col >> 3, map(ord, color)) r, g, b = map(lambda col : col >> 3, map(ord, color))
value = (b << 10) + (g << 5) + r value = (b << 10) + (g << 5) + r
pal_output.write(struct.pack("<h", value)) pal_output.write(struct.pack("<h", value))