From 025830c193acb353885f23b9f6d95fdfa466d1cb Mon Sep 17 00:00:00 2001 From: Aleksandra Date: Mon, 27 Mar 2023 19:07:12 +0200 Subject: [PATCH] Allow to share palettes between modules (backported from ea6d19d) --- tools/png2c.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/png2c.py b/tools/png2c.py index 05f4f590..26e30475 100755 --- a/tools/png2c.py +++ b/tools/png2c.py @@ -396,10 +396,12 @@ def do_palette(im, desc): param = parse(desc, ('name', str), ('colors', int), + ('shared', bool, False), ('store_unused', bool, False)) name = param['name'] has_colors = param['colors'] + shared = param['shared'] store_unused = param['store_unused'] pal = im.getpalette() @@ -416,7 +418,7 @@ def do_palette(im, desc): cmap = [pal[i * 3:(i + 1) * 3] for i in range(colors)] - print('static const PaletteT %s = {' % name) + print('%sconst PaletteT %s = {' % ('' if shared else 'static ', name)) print(' .count = %d,' % len(cmap)) print(' .colors = {') for r, g, b in cmap: