Skip to content

Commit

Permalink
lv_img_conv: remove commented code, improve error messages, exit status
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroBurner committed Oct 19, 2023
1 parent 41e18c6 commit 4fa3d1f
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions src/resources/lv_img_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4fa3d1f

Please sign in to comment.