Working Python version for Commodore.
This commit is contained in:
commit
2a48f52979
51 changed files with 3095 additions and 0 deletions
29
c64view/gallery.py
Normal file
29
c64view/gallery.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Render every Mode x Palette x Dither variation of an image, for the GUI's
|
||||
"Explore variations" contact sheet. Kept import-light (no Qt) so it can run in
|
||||
ProcessPoolExecutor worker processes.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from . import imageprep
|
||||
from .convert import MODES, render_preview, convert_image
|
||||
|
||||
PALETTES = ["colodore", "pepto"]
|
||||
DITHERS = ["bayer", "floyd", "atkinson", "none"]
|
||||
|
||||
# (mode, palette, dither) for every concrete mode (auto is excluded on purpose).
|
||||
COMBOS = [(m, p, d) for m in MODES for p in PALETTES for d in DITHERS]
|
||||
|
||||
|
||||
def render_variation(args):
|
||||
"""Worker entry point. ``args`` = (path, mode, palette, dither, prep_kwargs).
|
||||
|
||||
Returns (mode, palette, dither, error, rgb) where rgb is the displayed-
|
||||
resolution (320x200) preview as a uint8 HxWx3 array.
|
||||
"""
|
||||
path, mode, palette, dither, prep_kwargs = args
|
||||
prep = imageprep.PrepOptions(**prep_kwargs)
|
||||
conv = convert_image(path, mode=mode, palette_name=palette,
|
||||
dither_mode=dither, intensive=False, prep_opt=prep)
|
||||
rgb = render_preview(conv, palette, scale=1)
|
||||
return (mode, palette, dither, conv.error, rgb)
|
||||
Loading…
Add table
Add a link
Reference in a new issue