From ce8aef737c3a0d6efa035c6ef634ba21ab0b6e42 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sat, 11 Jan 2014 14:14:46 +0100 Subject: 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 --- apps/recorder/bmp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apps/recorder') 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, 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) -- cgit v1.2.3