Intelligent pictures (format 4) and direction-aware picture order
Format 4 decoded from Editor output: control words of eight 4-bit ops (runs up to 13, 12-bit long runs, literal blocks) over 8 colour slots, plus a run-length 7-bit alpha section. The encoder reproduces all 28 Editor samples byte for byte and the Editor keeps our pictures as is. Pictures are stored rotated by the display direction, byte 0 of N.i is 0x0A + direction; this applies to format 0 too. add_picture now writes the right format and order for the project; the renderer decodes format 4 and blends alpha. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a93cb58b96
commit
193bcd5d97
8 files changed
+301
-56
No files matched your search
+9
-7
@@ -13,9 +13,9 @@ byte for byte, or a file written by nxhmi was opened in the Editor and showed th
|
||||
| Checksums (page, project header, file table) | **complete**, verified |
|
||||
| Components | **31 / 31 types** (20 Basic + 11 Intelligent-only) read/write/create |
|
||||
| Readable JSON (enum names, colours) | done for every value list the Editor documents |
|
||||
| Pictures | Basic series **complete**; Intelligent compressed format **missing** |
|
||||
| Pictures | **complete**: format 0 (Basic) and format 4 (Intelligent, with alpha), all display directions |
|
||||
| Fonts | black/white **complete** incl. generation from TrueType; anti-aliased **missing** |
|
||||
| Rendering pages like the Editor | **pixel-identical** for most components for every Basic component incl. picture skins, radios, gauges and QR codes |
|
||||
| Rendering pages like the Editor | **pixel-identical** for every Basic component incl. picture skins, radios, gauges and QR codes |
|
||||
| New projects from scratch | `project.new_project(model)` for 12 Basic/Intelligent models; the generated demo is byte-identical to the Editor's re-save |
|
||||
| Compiling `.tft` firmware | **research only** -- not possible yet |
|
||||
|
||||
@@ -60,9 +60,11 @@ byte for byte, or a file written by nxhmi was opened in the Editor and showed th
|
||||
`format`, `dir`, `en`, `mode`, `psta`, `dez`, variable type, QR logo -- taken from the Editor's
|
||||
own attribute notes. Colours as `#rrggbb`. Still round-trips byte for byte.
|
||||
|
||||
### Pictures (Basic series)
|
||||
- `N.i` (RGB565, panel-native rotated order) and `N.is` (original file) -- encoder output is
|
||||
byte-identical to the Editor's; adding pictures verified in the Editor.
|
||||
### Pictures
|
||||
- `N.i` format 0 (Basic, raw RGB565) and format 4 (Intelligent, run-length + 7-bit alpha), stored
|
||||
rotated for the display direction, and `N.is` (original file) -- encoder output is
|
||||
byte-identical to the Editor's (format 4: 28 samples, all four directions); the Editor keeps
|
||||
our format-4 pictures unchanged; adding pictures verified in the Editor.
|
||||
|
||||
### Fonts
|
||||
- `.zi` version 6, black/white: decode/encode byte-identical to the Editor (224-glyph font).
|
||||
@@ -86,10 +88,10 @@ byte for byte, or a file written by nxhmi was opened in the Editor and showed th
|
||||
### `.HMI` side
|
||||
| Item | Notes |
|
||||
|---|---|
|
||||
| Intelligent picture format 4 | block codec with 8-bit alpha; first findings in FORMAT.md |
|
||||
| Picture quality below 100 (Editor picture list "Q:") | not studied |
|
||||
| Anti-aliased fonts, multi-byte encodings (GB2312, Big5, ...) | only B/W single-byte fonts seen |
|
||||
| Other display series | Discovery / Enhanced / Edge not sampled; only Basic + Intelligent templates |
|
||||
| Display direction | byte 12 decoded and written (`new_project(portrait=...)`); picture/glyph order verified for one direction (90° Basic) only |
|
||||
| Display direction | byte 12 decoded and written (`new_project(portrait=...)`); picture order verified for all four (format 4); font glyph order for 90° only |
|
||||
| Some header fields | main.HMI bytes 8, 13, 36, 0x41; page header 21/23; entry bytes 25-27 |
|
||||
| Font name shown in the Editor's Fonts panel | cosmetic, generated fonts show an odd label |
|
||||
| Media resources | video / audio / Gmov files themselves (not just the components) |
|
||||
|
||||
+31
-8
@@ -204,15 +204,38 @@ PNG that was imported):
|
||||
Format 0: RGB565 little-endian, converted by plain truncation (`r>>3, g>>2, b>>3`), stored in the
|
||||
panel's native scan order -- column by column, each column bottom-to-top:
|
||||
`offset = 2 * (x * height + (height - 1 - y))`. Verified pixel-exact (480×320 and 64×64, Editor
|
||||
output byte-identical to ours). **OPEN**: whether the order changes with the project's display
|
||||
direction (all samples: main.HMI byte 12 = 1, i.e. 90° on a Basic panel).
|
||||
output byte-identical to ours). The order follows the display direction, see format 4.
|
||||
|
||||
Format 4 (Intelligent series, **OPEN**): header field at 20 is non-zero for small pictures
|
||||
(e.g. 2640 for a 3307-byte payload); payload starts with u32 1, u32 height, u32 width (note:
|
||||
swapped vs. the header, i.e. panel orientation), ... then a block codec: runs of RGB565 colours
|
||||
followed by small index bytes (e.g. `18c6 38c6 18c6 38c6 2131 1111`), with a variable number of
|
||||
bytes per 4x4 block, and full 8-bit alpha (a PNG with 256 alpha levels was imported). A 480x320
|
||||
photo compresses to 215,052 bytes at "Q:100".
|
||||
Format 4 (Intelligent series) -- decoded and re-encoded byte-identically (28 Editor samples, all
|
||||
four directions, with and without alpha):
|
||||
|
||||
- Header as above; byte 0 = 0x0A + display direction (also for format 0: a landscape Basic
|
||||
project, direction 1, writes 0x0B); +16 data length; +20 offset of the alpha section within the
|
||||
data (0 = opaque picture).
|
||||
- Pixel order: the picture rotated by the display direction (`pictures.stored_order`): 0 = row
|
||||
by row, 1 = column by column bottom to top (same as format 0 on Basic), 2 = 180°, 3 = columns
|
||||
from the right, top down.
|
||||
- Data: u32 1, u32 stored width, u32 stored height (swapped for directions 1/3), u32 0, u32 0,
|
||||
then blocks. A block is a u32 control word of eight 4-bit ops (low nibble first):
|
||||
- `1`..`13`: run of that many pixels in the colour of the op's slot (slot = nibble index);
|
||||
- `14`: run of N pixels, N in the next three nibbles (12 bits), colour of the op's slot;
|
||||
- `15`: N literal pixels (N in the next three nibbles); their colours follow the control
|
||||
word and end the block;
|
||||
- `0`: nothing.
|
||||
|
||||
Run blocks carry 8 colour slots (RGB565 LE) after the control word; the last block is padded
|
||||
with zero slots to 8.
|
||||
- How the Editor encodes: split the pixels into runs of one colour of at most 13; pack 8 runs
|
||||
per block; a block of eight 13-runs of one colour becomes op 14 (consecutive such blocks merge,
|
||||
N = 104 × blocks, at most 39); a block of eight single pixels becomes a literal block
|
||||
(consecutive ones merge, N = 8 × blocks).
|
||||
- Alpha section: 7-bit alpha (`a * 127 // 255`) per pixel in storage order, run-length coded --
|
||||
a byte with bit 7 set is one pixel of alpha `b & 0x7F`, otherwise `b` is the alpha and the next
|
||||
byte the run length (≤ 255). Fully transparent pixels store colour 0.
|
||||
- Pictures of 1-2 pixels stay format 0 (seen: 1x1, 2x1, 1x2; 8x1 is converted); nxhmi does the
|
||||
same. The Editor shows a message box per picture while converting format-0 pictures it finds
|
||||
in an Intelligent project.
|
||||
- **OPEN**: the "Q:100" quality shown in the Editor's picture list -- only quality 100 studied.
|
||||
|
||||
Adding a picture = `N.is` + `N.i` + a `i`/`N.i` resource-list entry (kept grouped with the other
|
||||
`i` entries) -- verified in the Editor.
|
||||
|
||||
Reference in new issue
Block a user