From b69d59ba8e06de799f7fc13c00e9d038867c38df Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 31 Jan 2006 23:34:02 +0000 Subject: [PATCH] Handle 8-bit BMP files git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8514 a1c6a512-1295-4272-9138-f99709370657 --- apps/recorder/bmp.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 5f596efdda..28e7281df0 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c @@ -297,6 +297,51 @@ int read_bmp_file(char* filename, #endif break; + + case 8: + p = bmpbuf; +#if LCD_DEPTH > 1 + if(format == FORMAT_MONO) { +#endif + /* 8-bit RGB24 palette -> mono */ + for (col = 0; col < width; col++) { + struct rgb_quad rgb = palette[*p]; + ret = brightness(rgb); + if (ret > 96) { + bitmap[width * ((height - row - 1) / 8) + col] + &= ~ 1 << ((height - row - 1) % 8); + } else { + bitmap[width * ((height - row - 1) / 8) + col] + |= 1 << ((height - row - 1) % 8); + } + p++; + } +#if LCD_DEPTH == 2 + } else { + /* 8-bit RGB24 palette -> 2gray (iriver H1xx) */ + for (col = 0; col < width; col++) { + struct rgb_quad rgb = palette[*p]; + ret = brightness(rgb); + + dest[((height - row - 1)/4) * width + col] |= + (~ret & 0xC0) >> (2 * (~(height - row - 1) & 3)); + p++; + } + } +#elif LCD_DEPTH == 16 + } else { + /* 8-bit RGB24 palette -> RGB16 */ + for (col = 0; col < width; col++) { + struct rgb_quad rgb = palette[*p]; + unsigned short rgb16 = + LCD_RGBPACK(rgb.red, rgb.green, rgb.blue); + dest[width * (height - row - 1) + col] = rgb16; + p++; + } + } +#endif + break; + case 24: p = bmpbuf; #if LCD_DEPTH > 1