From 4fa3d1fcc8767e00dfb124be00f96224b9ef0352 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Thu, 19 Oct 2023 22:31:24 +0200 Subject: [PATCH] lv_img_conv: remove commented code, improve error messages, exit status --- src/resources/lv_img_conv.py | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/resources/lv_img_conv.py b/src/resources/lv_img_conv.py index 8d84496f09..08f90eecfe 100755 --- a/src/resources/lv_img_conv.py +++ b/src/resources/lv_img_conv.py @@ -74,17 +74,17 @@ def main(): if args.force: print(f"overwriting {args.output_file}") else: - print(f"output-file exists, set --force to allow overwriting of file") - return 0 + pritn(f"Error: refusing to overwrite {args.output_file} without -f specified.") + return 1 out.touch() # only implemented the bare minimum, everything else is not implemented if args.color_format not in ["CF_INDEXED_1_BIT", "CF_TRUE_COLOR_ALPHA"]: - raise NotImplementedError(f"args.color_format '{args.color_format}' not implemented") + raise NotImplementedError(f"argument --color-format '{args.color_format}' not implemented") if args.output_format != "bin": - raise NotImplementedError(f"args.output_format '{args.output_format}' not implemented") + raise NotImplementedError(f"argument --output-format '{args.output_format}' not implemented") if args.binary_format not in ["ARGB8565_RBSWAP", "ARGB8888"]: - raise NotImplementedError(f"args.binary_format '{args.binary_format}' not implemented") + raise NotImplementedError(f"argument --binary-format '{args.binary_format}' not implemented") # open image using Pillow img = Image.open(img_path) @@ -126,29 +126,6 @@ def main(): buf[i + 0] = (c16 >> 8) & 0xFF buf[i + 1] = c16 & 0xFF buf[i + 2] = a - #buf_i0 = buf[i + 0] - #buf_i1 = buf[i + 1] - #buf_i2 = buf[i + 2] - #print(f"{x},{y}: {buf_i0:02x}, {buf_i1:02x}, {buf_i2:02x}") - #if (x == 8 and y == 2): - #if (x == 10 and y == 0): - # tmp_5 = 1 << (8 - 5) - # tmp_6 = 1 << (8 - 6) - # r = pixel[0] - # g = pixel[1] - # b = pixel[2] - # val_r = round(r / tmp_5) * tmp_5 - # val_g = round(g / tmp_6) * tmp_6 - # val_b = round(b / tmp_5) * tmp_5 - # print("rgba:", r, g, b, a) - # print("rgba_act:", r_act, g_act, b_act, a) - # print("classify_pixel(r, 5):", "tmp:", tmp_5, "r/tmp:", r/tmp_5, "round(r/tmp):", round(r/tmp_5), "val:", val_r) - # print("classify_pixel(g, 6):", "tmp:", tmp_6, "g/tmp:", g/tmp_6, "round(g/tmp):", round(g/tmp_6), "val:", val_g) - # print("classify_pixel(b, 5):", "tmp:", tmp_5, "b/tmp:", b/tmp_5, "round(b/tmp):", round(b/tmp_5), "val:", val_b) - # print("c16:", c16) - # print(f"{x},{y}: {buf_i0:02x}, {buf_i1:02x}, {buf_i2:02x}") - # print("found it!") - print(f"done line {y}") elif args.color_format == "CF_INDEXED_1_BIT": # ignore binary format, use color format as binary format w = img_width >> 3