diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2006-10-11 18:12:36 +0000 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2006-10-11 18:12:36 +0000 |
| commit | bed0db213d01f15524c2f1cf7795dfc0a2fe2bb6 (patch) | |
| tree | 2879a8d01e0f03bde65adf7d201500f9e74c41cc /apps/recorder | |
| parent | 6a4ec1414da6e393314abc389290cc2b57b387e6 (diff) | |
| download | rockbox-bed0db213d01f15524c2f1cf7795dfc0a2fe2bb6.zip rockbox-bed0db213d01f15524c2f1cf7795dfc0a2fe2bb6.tar.gz rockbox-bed0db213d01f15524c2f1cf7795dfc0a2fe2bb6.tar.bz2 rockbox-bed0db213d01f15524c2f1cf7795dfc0a2fe2bb6.tar.xz | |
Small bitmap dithering tweak
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11191 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder')
| -rw-r--r-- | apps/recorder/bmp.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 4b8ba16..f0f143f 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c @@ -97,14 +97,10 @@ inline int getpix(int px, unsigned char *bmpbuf) { #if LCD_DEPTH == 16 /* Cheapo 24 -> 16 bit dither */ -#if LCD_PIXELFORMAT == RGB565SWAPPED -#define RGBSWAPPED(rgb) swap16(rgb) -#else -#define RGBSWAPPED(rgb) rgb -#endif static unsigned short dither_24_to_16(struct rgb_quad rgb, int row, int col) { - static const unsigned char dith[2][16] = { + static const unsigned char dith[][16] = + { { /* 5 bit */ 0,6,1,7, 4,2,5,3, @@ -116,15 +112,25 @@ static unsigned short dither_24_to_16(struct rgb_quad rgb, int row, int col) 2,1,2,1, 0,3,0,3, 2,1,2,1 - } + }, }; const int elm = (row & 3) + ((col & 3) << 2); - short b = 31*((unsigned short)rgb.blue + dith[0][elm]) >> 8; - short g = 63*((unsigned short)rgb.green + dith[1][elm]) >> 8; - short r = 31*((unsigned short)rgb.red + dith[0][elm]) >> 8; + unsigned short color; + + unsigned b = ((unsigned)rgb.blue + dith[0][elm]) >> 3; + if (b > 0x1f) b = 0x1f; + unsigned g = ((unsigned)rgb.green + dith[1][elm]) >> 2; + if (g > 0x3f) g = 0x3f; + unsigned r = ((unsigned)rgb.red + dith[0][elm]) >> 3; + if (r > 0x1f) r = 0x1f; + + color = (unsigned short)(b | (g << 5) | (r << 11)); - return RGBSWAPPED(b | (g << 5) | (r << 11)); +#if LCD_PIXELFORMAT == RGB565SWAPPED + swap16(color); +#endif + return color; } #endif /* LCD_DEPTH == 16 */ |