First public commit.
This commit is contained in:
parent
2a48f52979
commit
4bac9d83ed
288 changed files with 18417 additions and 1076 deletions
20
lenser/apple/convert/__init__.py
Normal file
20
lenser/apple/convert/__init__.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
"""Apple II conversion dispatch."""
|
||||
from __future__ import annotations
|
||||
from ... import imageprep
|
||||
from . import hgr_mono
|
||||
|
||||
_MODULES = {"hgr_mono": hgr_mono}
|
||||
for _name in ("dhgr", "hgr_color", "mono"):
|
||||
try:
|
||||
_MODULES[_name] = __import__(f"lenser.apple.convert.{_name}", fromlist=[_name])
|
||||
except Exception:
|
||||
pass
|
||||
MODES = list(_MODULES.keys())
|
||||
|
||||
def convert_image(path_or_img, mode="hgr_mono", palette_name="mono",
|
||||
dither_mode="floyd", intensive=False, prep_opt=None, base_color=None):
|
||||
prep_opt = prep_opt or imageprep.PrepOptions()
|
||||
module = _MODULES[mode]
|
||||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue