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>
This commit is contained in:
parent
0edee8067e
commit
ed4a5503ba
1 changed files with 12 additions and 10 deletions
|
@ -350,29 +350,31 @@ parser.add_argument('--c', action='store_true',
|
||||||
help='Render the output as C instead of python')
|
help='Render the output as C instead of python')
|
||||||
parser.add_argument('--indent', default=0, type=int,
|
parser.add_argument('--indent', default=0, type=int,
|
||||||
help='Add extra indentation in the generated code')
|
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')
|
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')
|
help='Generate 8-bit image')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.eightbit:
|
if args.depth == 8:
|
||||||
encoder = encode_8bit
|
encoder = encode_8bit
|
||||||
depth = 8
|
elif args.depth == 2:
|
||||||
elif args.twobit:
|
|
||||||
encoder = encode_2bit
|
encoder = encode_2bit
|
||||||
depth = 2
|
elif args.depth == 1:
|
||||||
else:
|
|
||||||
encoder = encode
|
encoder = encode
|
||||||
depth =1
|
else:
|
||||||
|
encoder = encode_2bit
|
||||||
|
args.depth = 2
|
||||||
|
|
||||||
for fname in args.files:
|
for fname in args.files:
|
||||||
image = encoder(Image.open(fname))
|
image = encoder(Image.open(fname))
|
||||||
|
|
||||||
if args.c:
|
if args.c:
|
||||||
render_c(image, fname, args.indent, depth)
|
render_c(image, fname, args.indent, args.depth)
|
||||||
else:
|
else:
|
||||||
render_py(image, fname, args.indent, depth)
|
render_py(image, fname, args.indent, args.depth)
|
||||||
|
|
||||||
if args.ascii:
|
if args.ascii:
|
||||||
print()
|
print()
|
||||||
|
|
Loading…
Reference in a new issue