-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lv_img_conf_py: add initial skeleton enough to be called with same args
- Loading branch information
1 parent
87c6f92
commit e983549
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |