comparison img2tiles.py @ 8:a049de420cc1

Make number of static and dynamic colors command line arguments to img2tiles.py
author Mike Pavone <pavone@retrodev.com>
date Tue, 03 Sep 2013 09:49:29 -0700
parents a74776d80f95
children 997690aa0507
comparison
equal deleted inserted replaced
7:4ffd621f1d0c 8:a049de420cc1
210 def main(argv): 210 def main(argv):
211 if len(argv) < 3: 211 if len(argv) < 3:
212 print "Not enough arguments" 212 print "Not enough arguments"
213 return 213 return
214 fname = argv[1] 214 fname = argv[1]
215 static_colors = 8
216 dynamic_colors = 8
217 if len(argv) > 3:
218 static_colors = int(argv[3])
219 dynamic_colors = min(dynamic_colors, 16-static_colors)
220 if len(argv) > 4:
221 dynamic_colors = int(argv[4])
222 if dynamic_colors + static_colors > 16:
223 print "No more than 16 combined dynamic and static colors are allowed"
224 return
215 im = Image.open(fname) 225 im = Image.open(fname)
216 pal = make_palette(im, threshold, 8, 8) 226 pal = make_palette(im, threshold, static_colors, dynamic_colors)
217 palpix = trans_image(im, threshold, pal) 227 palpix = trans_image(im, threshold, pal)
218 tiles = to_tiles(palpix) 228 tiles = to_tiles(palpix)
219 bits = add_pal_entries(tiles, pal) 229 bits = add_pal_entries(tiles, pal)
220 out = open(argv[2], 'wb') 230 out = open(argv[2], 'wb')
221 out.write(tiles) 231 out.write(tiles)