Skip to content

Commit

Permalink
lv_img_conf_py: add initial skeleton enough to be called with same args
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroBurner committed Sep 18, 2023
1 parent 87c6f92 commit e983549
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions img/lv_img_conv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
import argparse
import pathlib
import sys

parser = argparse.ArgumentParser()

parser.add_argument("img",
help="Path to image to convert to C header file")
parser.add_argument("-o", "--output-file",
help="output file path (for single-image conversion)",
required=True)
parser.add_argument("-f", "--force",
help="allow overwriting the output file",
action="store_true")
# --image-name, -i name of image structure
parser.add_argument("-c", "--color-format",
help="color format of image",
default="CF_TRUE_COLOR_ALPHA",
choices=[
"CF_ALPHA_1_BIT", "CF_ALPHA_2_BIT", "CF_ALPHA_4_BIT",
"CF_ALPHA_8_BIT", "CF_INDEXED_1_BIT", "CF_INDEXED_2_BIT", "CF_INDEXED_4_BIT",
"CF_INDEXED_8_BIT", "CF_RAW", "CF_RAW_CHROMA", "CF_RAW_ALPHA",
"CF_TRUE_COLOR", "CF_TRUE_COLOR_ALPHA", "CF_TRUE_COLOR_CHROMA", "CF_RGB565A8",
],
required=True)
parser.add_argument("-t", "--output-format",
help="output format of image",
default="bin", # default in original is 'c'
choices=["c", "bin"])
parser.add_argument("--binary-format",
help="binary color format (needed if output-format is binary)",
default="ARGB8565_RBSWAP",
choices=["ARGB8332", "ARGB8565", "ARGB8565_RBSWAP", "ARGB8888"])
# --swap-endian, -s swap endian of image [boolean]
# --dither, -d enable dither [boolean]
args = parser.parse_args()

img = pathlib.Path(args.img)
out = pathlib.Path(args.output_file)
if not img.is_file():
print(f"Input file is missing: '{args.img}'")
sys.exit(1)
if out.exists():
if args.force:
print(f"overwriting existing output-file: '{args.output_file}'")
else:
print(f"output-file exists, set --force to allow overwriting of file")
sys.exit(0)
out.touch()

0 comments on commit e983549

Please sign in to comment.