All five display series; exact component colours; Editor's literal rule for format 4

- 15 more models (Discovery, Enhanced, Edge, NX8048P043): ids and series bytes 1/6/100 from the
  Editor; native orientation per series; Discovery/Enhanced/Edge use the Basic templates
- per series picture format and storage direction: Enhanced like Basic, Edge format 4,
  Discovery format 3 (20 zero bytes + raw RGB565) always stored row by row; fonts likewise
- component colours are scaled (v*255//31) on every series -- exact against the canvas with zero
  tolerance; format-0 pictures stay bit-replicated
- format-4 encoder: literal pixels when the next 8 runs cover <= 10 pixels (7+ runs), 8 pixels at
  a time -- reproduces the Editor on 12 designed patterns plus the 28 earlier samples

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-16 14:35:50 +01:00
1 parent 922ca21f0f
commit ec35ceb615
9 files changed
+145 -62

No files matched your search

+18
View File
@@ -46,6 +46,24 @@ class NewProject(unittest.TestCase):
self.assertEqual(main[11], series)
self.assertEqual(Page.parse(h.read("0.pa")).components[0].get("w"), w)
def test_series_storage(self):
# measured in Editor 1.68: picture format and storage direction per series
import io
from PIL import Image
from nxhmi import fonts
im = Image.new("RGB", (5, 3), (10, 200, 30)); b = io.BytesIO(); im.save(b, "PNG")
cases = {"NX4832T035_011": (0x0B, 0), "NX4832K035_011": (0x0B, 0), "NX4832F035_011": (0x0A, 3),
"NX4848E040_011": (0x0B, 4), "NX4827P043_011": (0x0A, 4)}
for name, (b0, fmt) in cases.items():
h = project.new_project(name)
project.add_picture(h, b.getvalue())
project.add_font(h, fonts.from_ttf(None, 8))
pic, zi = h.read("0.i"), h.read("0.zi")
self.assertEqual((pic[0], pic[3]), (b0, fmt), name)
self.assertEqual(zi[3], b0, name) # fonts are stored like pictures
self.assertEqual(models.SERIES[100], "Discovery")
self.assertEqual(models.page_size("NX4880E043_011", 0), (480, 800)) # Edge 4.3": portrait native
def test_unknown_model(self):
with self.assertRaises(KeyError):
project.new_project("NX0000X000_000")