summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-08-14 00:13:09 +0100
committerVincent Sanders <vince@kyllikki.org>2016-08-14 00:13:09 +0100
commit202859d092da53a8d6729badf91801a60fe024cb (patch)
tree1bcb6354c75acf758ea84250d14f9ec1a8486dfb
parent6dadfdcac3331d8f0a56342b973c59872f954e3c (diff)
downloadlibnsbmp-202859d092da53a8d6729badf91801a60fe024cb.tar.gz
libnsbmp-202859d092da53a8d6729badf91801a60fe024cb.tar.bz2
futher fixes to RLE decoding to cope with top down decoding
-rw-r--r--src/libnsbmp.c25
1 files 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;