1
0
Fork 0

rle_encode: Include the image size in the comments

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2021-06-20 10:18:27 +01:00
parent ab84121d62
commit c373bc4d77

View file

@ -271,13 +271,15 @@ def encode_8bit(im):
def render_c(image, fname, indent, depth): def render_c(image, fname, indent, depth):
extra_indent = ' ' * indent extra_indent = ' ' * indent
if len(image) == 3: if len(image) == 3:
print(f'{extra_indent}// {depth}-bit RLE, generated from {fname}, '
f'{len(image[2])} bytes')
(x, y, pixels) = image (x, y, pixels) = image
print(f'{extra_indent}// {depth}-bit RLE, {x}x{y}, generated from {fname}, '
f'{len(image[2])} bytes')
else: else:
print(f'{extra_indent}// {depth}-bit RLE, generated from {fname}, ' x = image[1]
f'{len(image)} bytes') y = image[2]
pixels = image 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}static const uint8_t {varname(fname)}[] = {{')
print(f'{extra_indent} ', end='') print(f'{extra_indent} ', end='')
@ -294,15 +296,17 @@ def render_c(image, fname, indent, depth):
def render_py(image, fname, indent, depth): def render_py(image, fname, indent, depth):
extra_indent = ' ' * indent extra_indent = ' ' * indent
if len(image) == 3: if len(image) == 3:
print(f'{extra_indent}# {depth}-bit RLE, generated from {fname}, '
f'{len(image[2])} bytes')
(x, y, pixels) = image (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}{varname(fname)} = (')
print(f'{extra_indent} {x}, {y},') print(f'{extra_indent} {x}, {y},')
else: else:
print(f'{extra_indent}# {depth}-bit RLE, generated from {fname}, ' x = image[1]
f'{len(image)} bytes') y = image[2]
pixels = image[3:] 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}{varname(fname)} = (')
print(f'{extra_indent} {image[0:1]}') print(f'{extra_indent} {image[0:1]}')
print(f'{extra_indent} {image[1:3]}') print(f'{extra_indent} {image[1:3]}')