A Zig library for driving Elgato Stream Deck devices over USB HID.

Encode through z2dimg instead of zigimg

z2dimg writes a `z2d.Surface` straight out as BMP or JPEG, which is what this library has wanted all along: images are drawn on a surface, and the only reason zigimg was here was that it had the encoders. That removes the conversion between the two libraries' image types, and with it `image.convert`, which copied a surface pixel by pixel into a zigimg image in whichever channel order that format's encoder took. What is left is `image.transform`, surface in and surface out, applying only the rotation and the flips a display needs; the channel order is the encoder's business now, which is where it belongs. Three pieces of scaffolding go with it: - **The buffer arithmetic.** zigimg's `writeToMemory` writes into a buffer it will not grow, so both encoders sized one up front by a formula guessed at from the pixel count. z2dimg writes to a `*std.Io.Writer`, so `Writer.Allocating` grows it and the guess is gone. It was a latent bug waiting for an input it did not fit. - **The TGA workaround.** Both files carried a paragraph explaining why they reached past `Image.writeToMemory` to the one encoder they wanted: naming it referenced every format zigimg can write, and its TGA encoder segfaults the Zig 0.16.0 compiler. - **The JFIF segment.** zigimg writes no APP0, so this library prepended one by hand on the grounds that no Stream Deck has ever been shown to decode a bare stream. z2dimg emits JFIF itself. z2dimg also already knows this hardware: the `.rgb24` depth `bmp.zig` now asks for by name is documented there as what "the Elgato Stream Deck Original and Mini take exactly and nothing else", rather than being whatever the default happened to be. z2d is pinned to 0.12.1, which is what z2dimg depends on, down from the 0.12.2-pre this used before. The two have to agree: two z2d packages in one graph are two different `Surface` types, and a surface drawn here could not then be handed to an encoder there. Checked rather than assumed: the JPEG that goes over the wire decodes through an independent decoder to the same pre-flipped figures as before, byte for byte the same 1605 bytes, and `file` still reads it as JFIF 1.01 baseline 72x72 with three components. 70 tests pass, 90,000 fuzzed inputs find nothing, and the tree was run against a Stream Deck Original V2. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015oSWV37KApzcU2mL9C3U1J


Author jcollie.dev
Co-author Claude Opus 5 (1M context) Date Commit Parent 8c94251c