4 releases (breaking)
0.4.0 | Jul 10, 2023 |
---|---|
0.3.0 | May 17, 2023 |
0.2.0 | May 12, 2023 |
0.1.0 | Apr 4, 2023 |
#701 in Images
199 downloads per month
45KB
954 lines
Reference implementation for the Q565 image format.
Q565 is heavily based on the QOI Image format, but altered to support the 16-bit RGB565 pixel format (and that format only).
Differences from QOI
Header
- 4-byte magic:
q565
- u16le width (non-zero)
- u16le height (non-zero)
Color array
Q565 uses a simplified color array compared to the one from QOI. The "hash" function was replaced with just adding the bytes of the RGB565 u16 together and keeping the lowest 6 bits of the result. This resulted in smaller images on average and has the additional bonus of eliminating the last usage of multiplication in the decoder loop, making it reasonably fast even on microcontrollers without fast multiplication support.
In addition, pixels that can already be described in one byte are not added to the color array
(Q565_OP_DIFF
). This helps keep the color array from being
flooded with similar colors.
Q565_OP_DIFF_INDEXED
Since we only have 5/6 bits per channel, Q565_OP_LUMA
was reduced to represent the green
channel difference with just 5 instead of 6 bits. The gained bit is now used as part of the tag,
to discern between the new Q565_OP_DIFF_INDEXED
and
Q565_OP_LUMA
.
Q565_OP_DIFF_INDEXED
is similar to Q565_OP_DIFF
, but instead applies
the difference to a color from the color array. This results in an up to 5% smaller image size,
at the expense of a slower encoder (needing to calculate up to 64 color differences in the worst
case). If a faster encoder is needed, this operation can be omitted.
Stream format
See [consts] for the different operation types.
Dependencies
~2MB
~48K SLoC