From 202859d092da53a8d6729badf91801a60fe024cb Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 14 Aug 2016 00:13:09 +0100 Subject: futher fixes to RLE decoding to cope with top down decoding --- src/libnsbmp.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/libnsbmp.c b/src/libnsbmp.c index dc73d94..18ff002 100644 --- a/src/libnsbmp.c +++ b/src/libnsbmp.c @@ -976,7 +976,11 @@ static bmp_result bmp_decode_rle(bmp_image *bmp, uint8_t *data, int bytes, int s y++; if (y >= bmp->height) return BMP_DATA_ERROR; - scanline -= bmp->width; + if (bmp->reversed) { + scanline += bmp->width; + } else { + scanline -= bmp->width; + } } if (idx >= bmp->colours) return BMP_DATA_ERROR; @@ -989,7 +993,12 @@ static bmp_result bmp_decode_rle(bmp_image *bmp, uint8_t *data, int bytes, int s y++; if (y >= bmp->height) return BMP_DATA_ERROR; - scanline -= bmp->width; + if (bmp->reversed) { + scanline += bmp->width; + } else { + scanline -= bmp->width; + } + } if ((i & 1) == 0) { pixel = *data++; @@ -1040,7 +1049,11 @@ static bmp_result bmp_decode_rle(bmp_image *bmp, uint8_t *data, int bytes, int s y++; if (y >= bmp->height) return BMP_DATA_ERROR; - scanline -= bmp->width; + if (bmp->reversed) { + scanline += bmp->width; + } else { + scanline -= bmp->width; + } } scanline[x++] = pixel; } @@ -1057,7 +1070,11 @@ static bmp_result bmp_decode_rle(bmp_image *bmp, uint8_t *data, int bytes, int s y++; if (y >= bmp->height) return BMP_DATA_ERROR; - scanline -= bmp->width; + if (bmp->reversed) { + scanline += bmp->width; + } else { + scanline -= bmp->width; + } } if ((i & 1) == 0) scanline[x++] = pixel; -- cgit v1.2.3