22 lines
922 B
Python
22 lines
922 B
Python
"""CPC Mode 0: 160x200, 16 colours from the 27-colour palette (the flagship
|
|
photo mode -- wide pixels but the most colour)."""
|
|
from __future__ import annotations
|
|
|
|
from ...convert.base import Conversion, perceptual_error
|
|
from . import _common
|
|
|
|
WIDTH, HEIGHT = 160, 200
|
|
PIXEL_ASPECT = 2.0 # 160x200 on a 4:3 screen -> pixels twice as wide
|
|
NCOL = 16
|
|
|
|
|
|
def convert(img_rgb, palette_name="cpc", dither_mode="floyd",
|
|
intensive=False, base_color=None):
|
|
pen, inks, idx, img_lab, plab, prgb = _common.render(img_rgb, NCOL, dither_mode)
|
|
screen = _common.PACK[0](pen)
|
|
return Conversion(
|
|
mode="mode0", width=WIDTH, height=HEIGHT, pixel_aspect=PIXEL_ASPECT,
|
|
index_image=idx, data=screen, data_addr=0xC000, viewer="cpc",
|
|
preview_rgb=prgb[idx], error=perceptual_error(idx, img_lab, plab),
|
|
meta={"palette": "cpc", "dither": dither_mode, "cpc_mode": 0, "inks": inks},
|
|
)
|