22 lines
877 B
Python
22 lines
877 B
Python
"""NES monochrome: 256x240 greyscale using the PPU's grey ramp (tone by
|
|
dithering). ``--mono-base`` tints the ramp toward a hue."""
|
|
from __future__ import annotations
|
|
|
|
from ...convert.base import Conversion
|
|
from . import _common
|
|
|
|
WIDTH, HEIGHT = 256, 240
|
|
PIXEL_ASPECT = 1.0
|
|
|
|
|
|
def convert(img_rgb, palette_name="nes", dither_mode="floyd",
|
|
intensive=False, base_color=None):
|
|
subs = _common.pick_subpalettes(img_rgb, mono=True, base_color=base_color)
|
|
pal32, nt, chr_rom, idx, err, plab, prgb = _common.encode(
|
|
img_rgb, dither_mode, subs)
|
|
return Conversion(
|
|
mode="mono", width=WIDTH, height=HEIGHT, pixel_aspect=PIXEL_ASPECT,
|
|
index_image=idx, data={"palette": pal32, "nametable": nt, "chr": chr_rom},
|
|
data_addr=0, viewer="nes", preview_rgb=prgb[idx], error=err,
|
|
meta={"palette": "nes", "dither": dither_mode},
|
|
)
|