Crates.io | const_qoi |
lib.rs | const_qoi |
version | 1.0.1 |
source | src |
created_at | 2024-05-27 15:16:10.882761 |
updated_at | 2024-05-27 15:43:28.572528 |
description | A safe, 0 dependency, no_std streaming decoder/encoder library for the QOI (Quite Okay Image) format. |
homepage | https://github.com/auronandace/const_qoi |
repository | https://github.com/auronandace/const_qoi |
max_upload_size | |
id | 1253488 |
size | 89,258 |
A safe, 0 dependency, no_std streaming decoder/encoder library for the QOI (Quite Okay Image) format.
I wanted to understand the QOI specification and implement a decoder and encoder in a const context. Every public and private function is const including all the tests. This project helped me to better understand bitwise operations.
Both the decoder and the encoder maintain an array of 64 previously seen pixels and a seperate single previous pixel value.
This was the easier part of the specification to figure out and implement. After parsing the 14 byte header the steps for processing the input bytes as data chunks is straightforward:
For a streaming decoder the output goes into an intermediary buffer which requires additional considerations:
I found this more difficult to figure out and implement. There are some comparisons to make:
Based on those comparisons you select the appropriate QOI chunk to encode the pixel data into. The order is as follows:
Special consideration has to be taken for the very first pixel value from the input:
Please see https://crates.io/crates/const_qoi and the documentation section below.
Documentation can be found here: https://docs.rs/const_qoi