First public commit.
This commit is contained in:
parent
2a48f52979
commit
4bac9d83ed
288 changed files with 18417 additions and 1076 deletions
21
lenser/nes/convert/bg.py
Normal file
21
lenser/nes/convert/bg.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"""NES background image: 256x240, 4 sub-palettes (universal bg + 3 each), tiles."""
|
||||
from __future__ import annotations
|
||||
|
||||
from ...convert.base import Conversion
|
||||
from . import _common
|
||||
|
||||
WIDTH, HEIGHT = 256, 240
|
||||
PIXEL_ASPECT = 1.0 # NES pixels are ~square (8:7 really; close enough)
|
||||
|
||||
|
||||
def convert(img_rgb, palette_name="nes", dither_mode="floyd",
|
||||
intensive=False, base_color=None):
|
||||
subs = _common.pick_subpalettes(img_rgb, mono=False)
|
||||
pal32, nt, chr_rom, idx, err, plab, prgb = _common.encode(
|
||||
img_rgb, dither_mode, subs)
|
||||
return Conversion(
|
||||
mode="bg", 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},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue