"""Commodore Amiga conversion dispatch.""" from __future__ import annotations from ... import imageprep from . import lowres, mono # NOTE: HAM6 (4096 colours) was implemented and looks superb, but MAME's # preliminary Amiga can't render 6-bitplane/HAM modes cleanly (fixed-position # black bands at the screen edges), so only the MAME-verified 5-plane low-res # (32 colours) and mono modes are shipped. _MODULES = {"lowres": lowres, "mono": mono} MODES = list(_MODULES.keys()) def convert_image(path_or_img, mode="lowres", palette_name="amiga", dither_mode="floyd", intensive=False, prep_opt=None, base_color=None): prep_opt = prep_opt or imageprep.PrepOptions() module = _MODULES.get(mode, lowres) img_rgb = imageprep.prepare(path_or_img, module.WIDTH, module.HEIGHT, module.PIXEL_ASPECT, prep_opt, border_rgb=(0, 0, 0)) return module.convert(img_rgb, palette_name, dither_mode, intensive, base_color=base_color)