From c373bc4d777e0af3776dced9fb0da4a5f24cd40c Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Sun, 20 Jun 2021 10:18:27 +0100 Subject: [PATCH] rle_encode: Include the image size in the comments Signed-off-by: Daniel Thompson --- tools/rle_encode.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/rle_encode.py b/tools/rle_encode.py index b96ac62..83effba 100755 --- a/tools/rle_encode.py +++ b/tools/rle_encode.py @@ -271,13 +271,15 @@ def encode_8bit(im): def render_c(image, fname, indent, depth): extra_indent = ' ' * indent if len(image) == 3: - print(f'{extra_indent}// {depth}-bit RLE, generated from {fname}, ' - f'{len(image[2])} bytes') (x, y, pixels) = image + print(f'{extra_indent}// {depth}-bit RLE, {x}x{y}, generated from {fname}, ' + f'{len(image[2])} bytes') else: - print(f'{extra_indent}// {depth}-bit RLE, generated from {fname}, ' - f'{len(image)} bytes') + x = image[1] + y = image[2] pixels = image + print(f'{extra_indent}// {depth}-bit RLE, {x}x{y}, generated from {fname}, ' + f'{len(image)} bytes') print(f'{extra_indent}static const uint8_t {varname(fname)}[] = {{') print(f'{extra_indent} ', end='') @@ -294,15 +296,17 @@ def render_c(image, fname, indent, depth): def render_py(image, fname, indent, depth): extra_indent = ' ' * indent if len(image) == 3: - print(f'{extra_indent}# {depth}-bit RLE, generated from {fname}, ' - f'{len(image[2])} bytes') (x, y, pixels) = image + print(f'{extra_indent}# {depth}-bit RLE, {x}x{y}, generated from {fname}, ' + f'{len(image[2])} bytes') print(f'{extra_indent}{varname(fname)} = (') print(f'{extra_indent} {x}, {y},') else: - print(f'{extra_indent}# {depth}-bit RLE, generated from {fname}, ' - f'{len(image)} bytes') + x = image[1] + y = image[2] pixels = image[3:] + print(f'{extra_indent}# {depth}-bit RLE, {x}x{y}, generated from {fname}, ' + f'{len(image)} bytes') print(f'{extra_indent}{varname(fname)} = (') print(f'{extra_indent} {image[0:1]}') print(f'{extra_indent} {image[1:3]}')