66 if (buffer[0] !=
'q' || buffer[1] !=
'o' || buffer[2] !=
'i' || buffer[3] !=
'f') {
67 ESP_LOGE(TAG,
"Not a QOI file");
74 ESP_LOGE(TAG,
"Invalid image dimensions: (%zux%zu)", this->
width_, this->
height_);
77 uint8_t channels = buffer[12];
78 if (channels < 3 || channels > 4) {
79 ESP_LOGE(TAG,
"Unsupported number of channels: %d", channels);
83 uint8_t colorspace = buffer[13];
85 ESP_LOGE(TAG,
"Unsupported colorspace value: %d", colorspace);
88 ESP_LOGD(TAG,
"QOI image header: width=%zu, height=%zu, channels=%d, colorspace=%d", this->
width_, this->
height_,
89 channels, colorspace);
105 while (index < size && this->
paint_index_ < total_pixels) {
107 uint8_t
byte = buffer[index];
113 color.
r = buffer[index++];
114 color.
g = buffer[index++];
115 color.
b = buffer[index++];
118 }
else if (
byte == QOI_OP_RGBA) {
123 color.
r = buffer[index++];
124 color.
g = buffer[index++];
125 color.
b = buffer[index++];
126 color.
w = buffer[index++];
129 }
else if ((
byte & QOI_MASK_OP) ==
QOI_OP_RUN) {
132 for (
size_t i = 0; i < run_length; i++) {
143 uint8_t byte2 = buffer[index++];
145 color.
r += delta_g - 8 + ((byte2 >> 4) & 0x0f);
147 color.
b += delta_g - 8 + (byte2 & 0x0f);
152 color.
r += ((
byte >> 4) & 0x03) - 2;
153 color.
g += ((
byte >> 2) & 0x03) - 2;
154 color.
b += (
byte & 0x03) - 2;
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.