mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-18 17:42:36 -05:00
Handle 8-bit BMP files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8514 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
62b22ba45f
commit
b69d59ba8e
1 changed files with 45 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue