Merge pull request #84 from xfmoulet/master

Force a RGB source to have an alpha of 255
This commit is contained in:
Dominic Szablewski 2021-12-13 11:24:59 +01:00 committed by GitHub
commit 6a95206e35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
qoi.h
View File

@ -91,7 +91,7 @@ struct qoi_header_t {
uint8_t colorspace; // 0 = sRGB with linear alpha, 1 = all channels linear uint8_t colorspace; // 0 = sRGB with linear alpha, 1 = all channels linear
}; };
The decoder and encoder start with {r: 0, g: 0, b: 0, a: 0} as the previous The decoder and encoder start with {r: 0, g: 0, b: 0, a: 255} as the previous
pixel value. Pixels are either encoded as pixel value. Pixels are either encoded as
- a run of the previous pixel - a run of the previous pixel
- an index into an array of previously seen pixels - an index into an array of previously seen pixels
@ -389,7 +389,7 @@ void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len) {
qoi_rgba_t index[64] = {0}; qoi_rgba_t index[64] = {0};
int run = 0; int run = 0;
qoi_rgba_t px_prev = {.rgba = {.r = 0, .g = 0, .b = 0, .a = 0}}; qoi_rgba_t px_prev = {.rgba = {.r = 0, .g = 0, .b = 0, .a = 255}};
qoi_rgba_t px = px_prev; qoi_rgba_t px = px_prev;
int px_len = desc->width * desc->height * desc->channels; int px_len = desc->width * desc->height * desc->channels;
@ -514,7 +514,7 @@ void *qoi_decode(const void *data, int size, qoi_desc *desc, int channels) {
return NULL; return NULL;
} }
qoi_rgba_t px = {.rgba = {.r = 0, .g = 0, .b = 0, .a = 0}}; qoi_rgba_t px = {.rgba = {.r = 0, .g = 0, .b = 0, .a = 255}};
qoi_rgba_t index[64] = {0}; qoi_rgba_t index[64] = {0};
int run = 0; int run = 0;