summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-28 12:02:45 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2020-12-28 12:02:45 (GMT)
commited4a5503baa20d8004976561bb301ed7c01d5d96 (patch)
treea345c61341f9da68d6ce1234e04d76f622fe4ccc /tools
parent0edee8067e179f13564184ec9e253d8c45e6d8a7 (diff)
tools: rle_encode: Make 2-bit encoding the default
2-bit encoding is fully ROMable and therefore is more RAM efficient than the older 1-bit encoding. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/rle_encode.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/tools/rle_encode.py b/tools/rle_encode.py
index ed75342..510250b 100755
--- a/tools/rle_encode.py
+++ b/tools/rle_encode.py
@@ -350,29 +350,31 @@ parser.add_argument('--c', action='store_true',
help='Render the output as C instead of python')
parser.add_argument('--indent', default=0, type=int,
help='Add extra indentation in the generated code')
-parser.add_argument('--2bit', action='store_true', dest='twobit',
+parser.add_argument('--1bit', action='store_const', const=1, dest='depth',
+ help='Generate 1-bit image')
+parser.add_argument('--2bit', action='store_const', const=2, dest='depth',
help='Generate 2-bit image')
-parser.add_argument('--8bit', action='store_true', dest='eightbit',
+parser.add_argument('--8bit', action='store_const', const=8, dest='depth',
help='Generate 8-bit image')
args = parser.parse_args()
-if args.eightbit:
+if args.depth == 8:
encoder = encode_8bit
- depth = 8
-elif args.twobit:
+elif args.depth == 2:
encoder = encode_2bit
- depth = 2
-else:
+elif args.depth == 1:
encoder = encode
- depth =1
+else:
+ encoder = encode_2bit
+ args.depth = 2
for fname in args.files:
image = encoder(Image.open(fname))
if args.c:
- render_c(image, fname, args.indent, depth)
+ render_c(image, fname, args.indent, args.depth)
else:
- render_py(image, fname, args.indent, depth)
+ render_py(image, fname, args.indent, args.depth)
if args.ascii:
print()