Skip to content

Commit

Permalink
Allow to share palettes between modules (backported from ea6d19d)
Browse files Browse the repository at this point in the history
  • Loading branch information
spookbench authored and cahirwpz committed Dec 16, 2023
1 parent 727d4fa commit 025830c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/png2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down

0 comments on commit 025830c

Please sign in to comment.