8bitlenser/lenser/iigs/convert/mono.py
2026-07-03 19:35:35 -07:00

25 lines
1 KiB
Python

"""Apple IIGS SHR monochrome: 320x200 with a single 16-level grey palette (the
richest greyscale in lenser). ``--mono-base`` tints the ramp toward a colour."""
from __future__ import annotations
from ...convert.base import Conversion
from ...palette import get_palette
from . import _common
WIDTH, HEIGHT = 320, 200
PIXEL_ASPECT = 1.0
def convert(img_rgb, palette_name="iigs", dither_mode="floyd",
intensive=False, base_color=None):
base_rgb = None
if isinstance(base_color, int) and 0 <= base_color < 16:
base_rgb = get_palette("colodore")[base_color] # tint hue from C64 pal
block, preview, err = _common.encode(img_rgb, dither_mode, mono=True,
base_color=base_rgb)
return Conversion(
mode="mono", width=WIDTH, height=HEIGHT, pixel_aspect=PIXEL_ASPECT,
index_image=None, data=block, data_addr=0x2000, viewer="iigs",
preview_rgb=preview, error=err,
meta={"palette": "iigs", "dither": dither_mode},
)