diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-02 22:18:45 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-02 22:18:45 +0100 |
commit | fd54698d12d468420d344f0ff4d5e502e04d64d4 (patch) | |
tree | 62fbc4488e3374b27dddffe00de665894e7eec41 /liblss16_decode_to_colour_index.c | |
parent | First commit (diff) | |
download | liblss16-fd54698d12d468420d344f0ff4d5e502e04d64d4.tar.gz liblss16-fd54698d12d468420d344f0ff4d5e502e04d64d4.tar.bz2 liblss16-fd54698d12d468420d344f0ff4d5e502e04d64d4.tar.xz |
Add some functions needed fore encoding LSS16 files
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'liblss16_decode_to_colour_index.c')
-rw-r--r-- | liblss16_decode_to_colour_index.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/liblss16_decode_to_colour_index.c b/liblss16_decode_to_colour_index.c index 3d184c2..a552289 100644 --- a/liblss16_decode_to_colour_index.c +++ b/liblss16_decode_to_colour_index.c @@ -85,7 +85,7 @@ liblss16_decode_to_colour_index(struct liblss16_decoder *decoder, /* fall through */ case 4: - decoder->width = (uint16_t)*data++; + decoder->image.width = (uint16_t)*data++; ++*consumed_out; ++decoder->internal.init_state; if (!--length) @@ -93,7 +93,7 @@ liblss16_decode_to_colour_index(struct liblss16_decoder *decoder, /* fall through */ case 5: - decoder->width |= (uint16_t)((uint16_t)*data++ << 8); + decoder->image.width |= (uint16_t)((uint16_t)*data++ << 8); ++*consumed_out; ++decoder->internal.init_state; if (!--length) @@ -101,7 +101,7 @@ liblss16_decode_to_colour_index(struct liblss16_decoder *decoder, /* fall through */ case 6: - decoder->height = (uint16_t)*data++; + decoder->image.height = (uint16_t)*data++; ++*consumed_out; ++decoder->internal.init_state; if (!--length) @@ -109,13 +109,13 @@ liblss16_decode_to_colour_index(struct liblss16_decoder *decoder, /* fall through */ case 7: - decoder->height |= (uint16_t)((uint16_t)*data++ << 8); + decoder->image.height |= (uint16_t)((uint16_t)*data++ << 8); ++*consumed_out; ++decoder->internal.init_state; - decoder->internal.x_rem = decoder->width; - decoder->internal.y_rem = decoder->height; - if (!decoder->width || !decoder->height || decoder->height >> 15) { + decoder->internal.x_rem = decoder->image.width; + decoder->internal.y_rem = decoder->image.height; + if (!decoder->image.width || !decoder->image.height || decoder->image.height >> 15) { if (error_out) *error_out = LIBLSS16_DECODE_BAD_IMAGE_SIZE; return LIBLSS16_DECODE_ERROR; @@ -131,13 +131,13 @@ liblss16_decode_to_colour_index(struct liblss16_decoder *decoder, uint8_t value = *data++; ++*consumed_out; if (value & 0xC0) { - ((uint8_t *)decoder->colour_map)[i] = value; + ((uint8_t *)decoder->image.colour_map)[i] = value; if (error_out) *error_out = LIBLSS16_DECODE_BAD_COLOUR; return LIBLSS16_DECODE_ERROR; } else { value = (uint8_t)(((unsigned)value * 255U + 31U) / 63U); - ((uint8_t *)decoder->colour_map)[i] = value; + ((uint8_t *)decoder->image.colour_map)[i] = value; } if (!--length) @@ -184,7 +184,7 @@ liblss16_decode_to_colour_index(struct liblss16_decoder *decoder, } decoder->internal.x_rem -= m; if (!decoder->internal.x_rem) { - decoder->internal.x_rem = decoder->width; + decoder->internal.x_rem = decoder->image.width; decoder->internal.y_rem--; if (decoder->internal.saved > 1U) { if (error_out) |