Hello @AngusJohnson . Thank you for your great collection of QOI test images. I found your collection from the link you shared at the QOI repo:
phoboslab/qoi#132
I believe there is a bug in the 24-bpp QOI files in your collection.
For example, all QOI images in the /textures_photo folder issue their first pixel using the QOI_OP_RGBA code. This should probably be QOI_OP_RGB (because the images are opaque, and the spec requires starting with alpha = 255 as the "previous pixel value" anyway), but the more serious problem is that the 4-bytes issued in that first QOI_OP_RGBA include an alpha value of zero!
Because this is the only QOI_OP_RGBA issued in these images, the "last pixel seen" alpha value will remain at 0 for the remainder of the decode, rendering the entire image transparent.
Two simple fixes come to mind...
- Start opaque images with QOI_OP_RGB instead of QOI_OP_RGBA, or...
- If starting an opaque image with QOI_OP_RGBA, ensure the initial alpha value is stored as 255 instead of 0
Yes, a decoder could hypothetically check the number of channels in the QOI header and ignore alpha if 3 channels is listed, but I think this is not ideal as the QOI spec states:
"The colorspace and channel fields are purely informative. They do not change the way data chunks are encoded."
...So it's probably not ideal to assume a decoder would use header channel count to override QOI_OP_RGBA data found in the file.
Thank you for investigating!