Skip to content

Fix X2 raster orientation and compression - #28

Open
clanky1024 wants to merge 1 commit into
tomLadder:mainfrom
clanky1024:fix-x2
Open

Fix X2 raster orientation and compression#28
clanky1024 wants to merge 1 commit into
tomLadder:mainfrom
clanky1024:fix-x2

Conversation

@clanky1024

Copy link
Copy Markdown

Related to #17.

Summary

  • add a dedicated X2 device profile so its raster behavior can differ from M60
  • render X2 labels at exact integer dot dimensions without the legacy 90° rotation
  • compress X2 raster data using the vendor-compatible zlib parameters:
    • windowBits: 10
    • level: -1
    • memLevel: 8
    • strategy: 0
  • preserve the existing M60 rotation and fflate compression behavior
  • add focused regression coverage for the X2 zlib header and profile isolation

Root cause

The X2 print stream differed from the working LabelForge implementation in two raster-level details:

  • Thermoprint transmitted a 40×30 mm label as 240×320 instead of 320×240 pixels.
  • Thermoprint used the default 32 KiB zlib window (78 9C) instead of the vendor’s 1 KiB window (28 91).

The printer accepted the command stream and returned OK, but did not print the incompatible raster correctly.

Compatibility

The new behavior is selected only for devices advertising the X2 name prefix. M60 and other printer profiles retain their existing raster rotation and compression settings.

Validation

  • Successfully printed a 40×30 mm gap label on physical X2 hardware.
  • Added regression coverage for the 28 91 zlib header and X2/M60 profile isolation.

Attribution

The protocol analysis compared Thermoprint’s X2 implementation with the working implementation in the LabelForge project. The analysis and implementation were completed with assistance from the OpenAI Codex model.

@clanky1024
clanky1024 marked this pull request as ready for review August 17, 2026 10:38
@mschfh

mschfh commented Aug 23, 2026

Copy link
Copy Markdown

@tomLadder could this please be reviewed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants