summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-01-11 14:14:46 +0100
committerThomas Martitz <kugel@rockbox.org>2014-01-11 14:19:43 +0100
commitce8aef737c3a0d6efa035c6ef634ba21ab0b6e42 (patch)
treefd51f7fb7b14109aff58e1f84700f83e7ad74fbe
parent25e50ed8f1361ef3295aeb298a3edf2214f5b3b3 (diff)
downloadrockbox-ce8aef737c3a0d6efa035c6ef634ba21ab0b6e42.zip
rockbox-ce8aef737c3a0d6efa035c6ef634ba21ab0b6e42.tar.gz
rockbox-ce8aef737c3a0d6efa035c6ef634ba21ab0b6e42.tar.bz2
rockbox-ce8aef737c3a0d6efa035c6ef634ba21ab0b6e42.tar.xz
bmp loader: Fix loading of monochrome/greyscale BMPs with newer headers.
The code expected the color table at offset 54 (14+size of BITMAPINFOHEADER), which was after the BITMAPINFOHEADER header. However, newer BITMAPINFOHEADER versions exist which have more fields before the color table. Fix this by explicitely seeking to the color table. Change-Id: If1dfc77e7485e5a9e0bc0e7f577152da9358bd71
-rw-r--r--apps/recorder/bmp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c
index e4eb588..a6d6dd7 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -512,7 +512,7 @@ int read_bmp_fd(int fd,
int padded_width;
int read_width;
int depth, numcolors, compression, totalsize;
- int ret;
+ int ret, hdr_size;
bool return_size = format & FORMAT_RETURN_SIZE;
bool read_alpha = format & FORMAT_TRANSPARENT;
enum color_order order = BGRA;
@@ -675,13 +675,15 @@ int read_bmp_fd(int fd,
return -6;
}
+ hdr_size = letoh32(bmph.struct_size);
compression = letoh32(bmph.compression);
if (depth <= 8) {
numcolors = letoh32(bmph.clr_used);
if (numcolors == 0)
numcolors = BIT_N(depth);
+ /* forward to the color table */
+ lseek(fd, 14+hdr_size, SEEK_SET);
} else {
- int hdr_size = letoh32(bmph.struct_size);
numcolors = 0;
if (compression == 3) {
if (hdr_size >= 56)