First public commit.
This commit is contained in:
parent
2a48f52979
commit
4bac9d83ed
288 changed files with 18417 additions and 1076 deletions
35
lenser/c16/convert/mono.py
Normal file
35
lenser/c16/convert/mono.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"""C16 TED monochrome: 320x200, restricted to the TED's neutral grey ramp (8
|
||||
luminance levels of hue 1, plus black) for smooth greyscale. ``--mono-base``
|
||||
tints it toward one hue (black -> hue -> white). Two greys per 8x8 cell, packed
|
||||
into the same TED hires layout as the colour mode."""
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ...convert import base
|
||||
from .. import palette as tedpal
|
||||
from . import hires
|
||||
|
||||
WIDTH, HEIGHT = hires.WIDTH, hires.HEIGHT
|
||||
CELL_W, CELL_H = hires.CELL_W, hires.CELL_H
|
||||
PIXEL_ASPECT = hires.PIXEL_ASPECT
|
||||
|
||||
|
||||
def convert(img_rgb, palette_name="ted", dither_mode="floyd",
|
||||
intensive=False, base_color=None):
|
||||
plab = tedpal.palette_lab()
|
||||
prgb = tedpal.get_palette().astype(np.uint8)
|
||||
|
||||
ramp = base.luminance_ramp(plab, tedpal.GREYS, base_color)
|
||||
idx, sets, rows, cols, err = base.mono_render(
|
||||
img_rgb, plab, ramp, WIDTH, HEIGHT, CELL_W, CELL_H, dither_mode, n_free=2)
|
||||
|
||||
bitmap, attr, ch = hires._encode(idx, sets, rows, cols)
|
||||
payload = bytes(bitmap) + bytes(attr) + bytes(ch)
|
||||
|
||||
return base.Conversion(
|
||||
mode="mono", width=WIDTH, height=HEIGHT, pixel_aspect=PIXEL_ASPECT,
|
||||
index_image=idx.astype(np.uint16), data=payload, viewer="c16",
|
||||
preview_rgb=prgb[idx], error=err,
|
||||
meta={"palette": "ted", "dither": dither_mode, "border": 0},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue