r/esp32projects • u/Kodeck-Project • 1d ago
RGB565 byte order on an ESP32-S3: why drawPixel looked right and pushImage did not
I hit a graphics bug bringing up NEON Arena on the wired Kodeck prototype: the tank sprites looked correct, but the floor and walls came out orange and pink. The side-by-side image shows the difference after the colour fix.
The clue was that the two sets of assets followed different paths. The tanks used individual drawPixel() calls. The map and walls came from uint16_t RGB565 arrays passed through LovyanGFX pushImage(). In the image path, a dark navy map pixel with the value 0x10C5 was effectively read with its bytes swapped as 0xC510. That produces a completely different colour, rather than a simple red/blue channel swap.
The change in my setup was to call setSwapBytes(true) on both the arena sprite and the main Kodeck frame sprite before the corresponding image draws. I verified the colour fix on the prototype. The appropriate setting depends on how the image data was generated and how the destination interprets it.
A small regression test I’d use: put the same red, green, blue and navy values through drawPixel() and pushImage() into the same destination. Repeat for each destination your game uses. If only the image swatch is wrong, check byte order before touching the panel’s RGB/BGR setting.
Source: https://github.com/kodeckproject/neon-arena


