diff options
author | Juan J. MartÃnez <jjm@usebox.net> | 2021-06-02 07:56:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-02 07:56:28 +0100 |
commit | 279856dc3d1825f16c86d9d6624064cf4a45cd95 (patch) | |
tree | c333ba4818826dfde51597bdeae35a7ee89e903f | |
parent | 11bc8957c8bbbf9ebcf01d4ee620de48de36ea56 (diff) | |
parent | 0e4c10086b06fa7e65c4e1b230180edf0a490f49 (diff) | |
download | ubox-msx-lib-279856dc3d1825f16c86d9d6624064cf4a45cd95.tar.gz ubox-msx-lib-279856dc3d1825f16c86d9d6624064cf4a45cd95.zip |
Merge pull request #2 from pvmm/master
Optional comment with original frame color as reference.
-rwxr-xr-x | tools/png2sprites.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/png2sprites.py b/tools/png2sprites.py index a554433..2fb0054 100755 --- a/tools/png2sprites.py +++ b/tools/png2sprites.py @@ -59,6 +59,8 @@ def main(): help="variable name (default: sprites)") parser.add_argument("-a", "--asm", dest="asm", action="store_true", help="ASM output (default: C header)") + parser.add_argument("-c", "--colors", dest="colors", action="store_true", + help="print frame color as comment (default: false)") parser.add_argument("image", help="image to convert") @@ -81,6 +83,7 @@ def main(): data = image.getdata() out = [] + frame_colors = [] for y in range(0, h, DEF_H): for x in range(0, w, DEF_W): tile = [data[x + i + ((y + j) * w)] @@ -91,6 +94,7 @@ def main(): continue for c in cols: + frame_colors.append(c) frame = [] for i, j in ((0, 0), (0, 8), (8, 0), (8, 8)): for m in range(8): @@ -110,6 +114,10 @@ def main(): for i, frame in enumerate(out): print("%s_frame%d:" % (args.id, i)) + if args.colors: + print("\t; color: #%02x%02x%02x" % (frame_colors[i][0], + frame_colors[i][1], + frame_colors[i][2])) print(to_hex_list_str_asm(frame)) else: print("#ifndef _%s_H" % args.id.upper()) @@ -119,6 +127,10 @@ def main(): data_out = "" for i, frame in enumerate(out): + if args.colors: + data_out += '/* color: 0x%02x%02x%02x */\n' % (frame_colors[i][0], + frame_colors[i][1], + frame_colors[i][2]) data_out += '{\n' + to_hex_list_str(frame) + '}' if i + 1 < len(out): data_out += ',\n' |