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
+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