Mercurial > repos > ghero
diff img2tiles.py @ 9:997690aa0507
Improve method for choosing line palette entries. Read number of global and dynamic colors from image binary. Go back to doing a word, longword, word pattern of writes for turning off display, doing DMA and turning it back on again to make things work correctly on the real hardware.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 04 Sep 2013 00:41:52 -0700 |
parents | a049de420cc1 |
children | eddc4ba6b0c3 |
line wrap: on
line diff
--- a/img2tiles.py Tue Sep 03 09:49:29 2013 -0700 +++ b/img2tiles.py Wed Sep 04 00:41:52 2013 -0700 @@ -92,9 +92,17 @@ #linecolors = get_color_info_error(pixels, xrange(linestart, linestart+width), trans_thresh, glob_pal) linecolors = get_color_info_both(pixels, xrange(linestart, linestart+width), trans_thresh, glob_pal) line_pal = {} - for idx in xrange(0, min(max_line, len(linecolors))): - (count, color) = linecolors[idx] - line_pal[color] = idx + max_global + while len(line_pal) < max_line and len(linecolors): + (score, color) = linecolors[0] + line_pal[color] = len(line_pal) + max_global + if len(line_pal) < max_line: + combo = dict(glob_pal) + for color in line_pal: + combo[color] = line_pal[color] + linecolors = get_color_info_both(pixels, xrange(linestart, linestart+width), trans_thresh, combo) + #for idx in xrange(0, min(max_line, len(linecolors))): + # (count, color) = linecolors[idx] + # line_pal[color] = idx + max_global line_pals.append(line_pal) return (glob_pal, line_pals, max_global, max_line) @@ -189,6 +197,8 @@ def add_pal_entries(tiles, pal): (global_pal, line_pals, max_global, max_line) = pal + tiles.append(max_global) + tiles.append(max_line) pal_list = [(0, 0, 0)] * max_global for entry in global_pal: pal_list[global_pal[entry]] = entry @@ -216,7 +226,7 @@ dynamic_colors = 8 if len(argv) > 3: static_colors = int(argv[3]) - dynamic_colors = min(dynamic_colors, 16-static_colors) + dynamic_colors = 16-static_colors if len(argv) > 4: dynamic_colors = int(argv[4]) if dynamic_colors + static_colors > 16: