Add flags to show input/output images

This commit is contained in:
kris 2021-01-15 22:34:03 +00:00
parent ce99d62304
commit d57d6f9038

View File

@ -13,8 +13,10 @@ import screen as screen_py
# TODO:
# - only lookahead for 560px
# - support 140px mode again
# - compare to bmp2dhr and a2bestpix
# - support LR/DLR
# - support HGR
def main():
@ -30,6 +32,12 @@ def main():
'--dither', type=str, choices=list(dither_pattern.PATTERNS.keys()),
default=dither_pattern.DEFAULT_PATTERN,
help="Error distribution pattern to apply when dithering.")
parser.add_argument(
'--show_input', action=argparse.BooleanOptionalAction, default=False,
help="Whether to show the input image before conversion.")
parser.add_argument(
'--show_output', action=argparse.BooleanOptionalAction, default=True,
help="Whether to show the output image after conversion.")
args = parser.parse_args()
palette = palette_py.Palette()
@ -37,7 +45,8 @@ def main():
screen = screen_py.DHGR560Screen(palette)
image = image_py.open(screen.X_RES, screen.Y_RES, args.input)
# image_rgb.show()
if args.show_input:
Image.fromarray(image.astype(np.uint8)).show()
dither = dither_pattern.PATTERNS[args.dither]()
@ -51,7 +60,8 @@ def main():
np.uint8))
outfile = os.path.join(os.path.splitext(args.output)[0] + ".png")
out_image.save(outfile, "PNG")
out_image.show(title=outfile)
if args.show_output:
out_image.show()
# bitmap = Image.fromarray(screen.bitmap.astype('uint8') * 255)
with open(args.output, "wb") as f: