Compare commits

...

4 Commits

Author SHA1 Message Date
璀境石 c01d645ac0
Merge d5c624acc9 into 827a7e4418 2023-12-13 00:20:40 -07:00
Dominic Szablewski 827a7e4418
Merge pull request #292 from finnurthorisson/Add-Lua-LIL
Add Lua LIL
2023-12-11 13:25:07 +01:00
Finnur Þórisson bc8242a28d
Add Lua LIL 2023-12-11 10:26:13 +00:00
Kuanlan d5c624acc9 Resolve some warnings when MSVC warning level is 4 2022-08-21 10:56:29 +08:00
2 changed files with 12 additions and 11 deletions

View File

@ -144,6 +144,7 @@ either, as this "reference implementation" tries to be as easy to read as possib
- [n00bmind/qoi](https://github.com/n00bmind/qoi) - Jai
- [SixLabors/ImageSharp](https://github.com/SixLabors/ImageSharp) - C# image proccesing library
- [zertovitch/gid](https://github.com/zertovitch/gid) - Ada
- [nazrin/lil](https://codeberg.org/nazrin/lil) - Lua image library
## QOI Support in Other Software

22
qoi.h
View File

@ -339,10 +339,10 @@ typedef union {
static const unsigned char qoi_padding[8] = {0,0,0,0,0,0,0,1};
static void qoi_write_32(unsigned char *bytes, int *p, unsigned int v) {
bytes[(*p)++] = (0xff000000 & v) >> 24;
bytes[(*p)++] = (0x00ff0000 & v) >> 16;
bytes[(*p)++] = (0x0000ff00 & v) >> 8;
bytes[(*p)++] = (0x000000ff & v);
bytes[(*p)++] = (v >> 24) & 0xff;
bytes[(*p)++] = (v >> 16) & 0xff;
bytes[(*p)++] = (v >> 8) & 0xff;
bytes[(*p)++] = (v >> 0) & 0xff;
}
static unsigned int qoi_read_32(const unsigned char *bytes, int *p) {
@ -415,7 +415,7 @@ void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len) {
if (px.v == px_prev.v) {
run++;
if (run == 62 || px_pos == px_end) {
bytes[p++] = QOI_OP_RUN | (run - 1);
bytes[p++] = QOI_OP_RUN | (unsigned char)(run - 1);
run = 0;
}
}
@ -423,14 +423,14 @@ void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len) {
int index_pos;
if (run > 0) {
bytes[p++] = QOI_OP_RUN | (run - 1);
bytes[p++] = QOI_OP_RUN | (unsigned char)(run - 1);
run = 0;
}
index_pos = QOI_COLOR_HASH(px) % 64;
if (index[index_pos].v == px.v) {
bytes[p++] = QOI_OP_INDEX | index_pos;
bytes[p++] = QOI_OP_INDEX | (unsigned char)index_pos;
}
else {
index[index_pos] = px;
@ -566,9 +566,9 @@ void *qoi_decode(const void *data, int size, qoi_desc *desc, int channels) {
else if ((b1 & QOI_MASK_2) == QOI_OP_LUMA) {
int b2 = bytes[p++];
int vg = (b1 & 0x3f) - 32;
px.rgba.r += vg - 8 + ((b2 >> 4) & 0x0f);
px.rgba.g += vg;
px.rgba.b += vg - 8 + (b2 & 0x0f);
px.rgba.r += (signed char)(vg - 8 + ((b2 >> 4) & 0x0f));
px.rgba.g += (signed char)(vg);
px.rgba.b += (signed char)(vg - 8 + (b2 & 0x0f));
}
else if ((b1 & QOI_MASK_2) == QOI_OP_RUN) {
run = (b1 & 0x3f);
@ -638,7 +638,7 @@ void *qoi_read(const char *filename, qoi_desc *desc, int channels) {
return NULL;
}
bytes_read = fread(data, 1, size, f);
bytes_read = (int)fread(data, 1, size, f);
fclose(f);
pixels = (bytes_read != size) ? NULL : qoi_decode(data, bytes_read, desc, channels);
QOI_FREE(data);