summaryrefslogtreecommitdiff
path: root/apps/recorder
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 /apps/recorder
parent25e50ed8f1361ef3295aeb298a3edf2214f5b3b3 (diff)
downloadrockbox-ce8aef737c3a0d6efa035c6ef634ba21ab0b6e42.tar.gz
rockbox-ce8aef737c3a0d6efa035c6ef634ba21ab0b6e42.zip
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
Diffstat (limited to 'apps/recorder')
-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 e4eb588eb3..a6d6dd71b1 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -512,7 +512,7 @@ int read_bmp_fd(int fd,
512 int padded_width; 512 int padded_width;
513 int read_width; 513 int read_width;
514 int depth, numcolors, compression, totalsize; 514 int depth, numcolors, compression, totalsize;
515 int ret; 515 int ret, hdr_size;
516 bool return_size = format & FORMAT_RETURN_SIZE; 516 bool return_size = format & FORMAT_RETURN_SIZE;
517 bool read_alpha = format & FORMAT_TRANSPARENT; 517 bool read_alpha = format & FORMAT_TRANSPARENT;
518 enum color_order order = BGRA; 518 enum color_order order = BGRA;
@@ -675,13 +675,15 @@ int read_bmp_fd(int fd,
675 return -6; 675 return -6;
676 } 676 }
677 677
678 hdr_size = letoh32(bmph.struct_size);
678 compression = letoh32(bmph.compression); 679 compression = letoh32(bmph.compression);
679 if (depth <= 8) { 680 if (depth <= 8) {
680 numcolors = letoh32(bmph.clr_used); 681 numcolors = letoh32(bmph.clr_used);
681 if (numcolors == 0) 682 if (numcolors == 0)
682 numcolors = BIT_N(depth); 683 numcolors = BIT_N(depth);
684 /* forward to the color table */
685 lseek(fd, 14+hdr_size, SEEK_SET);
683 } else { 686 } else {
684 int hdr_size = letoh32(bmph.struct_size);
685 numcolors = 0; 687 numcolors = 0;
686 if (compression == 3) { 688 if (compression == 3) {
687 if (hdr_size >= 56) 689 if (hdr_size >= 56)