#ifndef DPA_QOI_H #define DPA_QOI_H #include #include #include // On AVR, you may want to define "qoi_byte" as "const __flash unsigned char" instead! #ifndef qoi_byte #define qoi_byte const unsigned char #endif struct qoi_color_rgba { unsigned char color[4]; // RGBA }; struct qoi_decoder { qoi_byte*restrict input; struct qoi_color_rgba current_color; struct qoi_color_rgba table[64]; unsigned char run; }; #define QOI_DECODER_INIT(INPUT) (struct qoi_decoder){ .input = (INPUT)+14, .current_color.color[3] = 0xFF, } static inline bool qoi_check_magic(qoi_byte*restrict a){ return a[0] == 'q' && a[1] == 'o' && a[2] == 'i' && a[3] == 'f'; } static inline uint32_t qoi_get_width (qoi_byte*restrict a){ return (uint32_t)a[4]<<24 | (uint32_t)a[5]<<16 | (uint32_t)a[ 6]<<8 | (uint32_t)a[ 7]; } static inline uint32_t qoi_get_height(qoi_byte*restrict a){ return (uint32_t)a[8]<<24 | (uint32_t)a[9]<<16 | (uint32_t)a[10]<<8 | (uint32_t)a[11]; } static inline unsigned char qoi_get_channels(qoi_byte*restrict a){ return a[12]; } static inline unsigned char qoi_get_colorspace(qoi_byte*restrict a){ return a[13]; } void qoi_decode(struct qoi_decoder*restrict state, size_t count, unsigned char*restrict output); #endif