diff options
Diffstat (limited to 'apps/recorder/bmp.c')
-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 4b8ba1681b..f0f143f442 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -97,14 +97,10 @@ inline int getpix(int px, unsigned char *bmpbuf) { | |||
97 | 97 | ||
98 | #if LCD_DEPTH == 16 | 98 | #if LCD_DEPTH == 16 |
99 | /* Cheapo 24 -> 16 bit dither */ | 99 | /* Cheapo 24 -> 16 bit dither */ |
100 | #if LCD_PIXELFORMAT == RGB565SWAPPED | ||
101 | #define RGBSWAPPED(rgb) swap16(rgb) | ||
102 | #else | ||
103 | #define RGBSWAPPED(rgb) rgb | ||
104 | #endif | ||
105 | static unsigned short dither_24_to_16(struct rgb_quad rgb, int row, int col) | 100 | static unsigned short dither_24_to_16(struct rgb_quad rgb, int row, int col) |
106 | { | 101 | { |
107 | static const unsigned char dith[2][16] = { | 102 | static const unsigned char dith[][16] = |
103 | { | ||
108 | { /* 5 bit */ | 104 | { /* 5 bit */ |
109 | 0,6,1,7, | 105 | 0,6,1,7, |
110 | 4,2,5,3, | 106 | 4,2,5,3, |
@@ -116,15 +112,25 @@ static unsigned short dither_24_to_16(struct rgb_quad rgb, int row, int col) | |||
116 | 2,1,2,1, | 112 | 2,1,2,1, |
117 | 0,3,0,3, | 113 | 0,3,0,3, |
118 | 2,1,2,1 | 114 | 2,1,2,1 |
119 | } | 115 | }, |
120 | }; | 116 | }; |
121 | 117 | ||
122 | const int elm = (row & 3) + ((col & 3) << 2); | 118 | const int elm = (row & 3) + ((col & 3) << 2); |
123 | short b = 31*((unsigned short)rgb.blue + dith[0][elm]) >> 8; | 119 | unsigned short color; |
124 | short g = 63*((unsigned short)rgb.green + dith[1][elm]) >> 8; | 120 | |
125 | short r = 31*((unsigned short)rgb.red + dith[0][elm]) >> 8; | 121 | unsigned b = ((unsigned)rgb.blue + dith[0][elm]) >> 3; |
122 | if (b > 0x1f) b = 0x1f; | ||
123 | unsigned g = ((unsigned)rgb.green + dith[1][elm]) >> 2; | ||
124 | if (g > 0x3f) g = 0x3f; | ||
125 | unsigned r = ((unsigned)rgb.red + dith[0][elm]) >> 3; | ||
126 | if (r > 0x1f) r = 0x1f; | ||
127 | |||
128 | color = (unsigned short)(b | (g << 5) | (r << 11)); | ||
126 | 129 | ||
127 | return RGBSWAPPED(b | (g << 5) | (r << 11)); | 130 | #if LCD_PIXELFORMAT == RGB565SWAPPED |
131 | swap16(color); | ||
132 | #endif | ||
133 | return color; | ||
128 | } | 134 | } |
129 | #endif /* LCD_DEPTH == 16 */ | 135 | #endif /* LCD_DEPTH == 16 */ |
130 | 136 | ||