diff options
-rw-r--r-- | apps/recorder/bmp.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 8fe7663286..130505b9bc 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -120,7 +120,7 @@ static inline uint32_t readlong(uint32_t *value) | |||
120 | return (uint32_t)bytes[0] | ((uint32_t)bytes[1] << 8) | | 120 | return (uint32_t)bytes[0] | ((uint32_t)bytes[1] << 8) | |
121 | ((uint32_t)bytes[2] << 16) | ((uint32_t)bytes[3] << 24); | 121 | ((uint32_t)bytes[2] << 16) | ((uint32_t)bytes[3] << 24); |
122 | } | 122 | } |
123 | 123 | ||
124 | static inline unsigned brightness(union rgb_union color) | 124 | static inline unsigned brightness(union rgb_union color) |
125 | { | 125 | { |
126 | return (3 * (unsigned)color.red + 6 * (unsigned)color.green | 126 | return (3 * (unsigned)color.red + 6 * (unsigned)color.green |
@@ -315,7 +315,7 @@ int read_bmp_file(char* filename, | |||
315 | uint16_t *p2; | 315 | uint16_t *p2; |
316 | uint32_t *rp; | 316 | uint32_t *rp; |
317 | union rgb_union *qp; | 317 | union rgb_union *qp; |
318 | union rgb_union q0, q1; | 318 | union rgb_union q0, q1; |
319 | 319 | ||
320 | /* read one row */ | 320 | /* read one row */ |
321 | ret = read(fd, bmpbuf, padded_width); | 321 | ret = read(fd, bmpbuf, padded_width); |
@@ -423,7 +423,7 @@ int read_bmp_file(char* filename, | |||
423 | /* Convert to destination format */ | 423 | /* Convert to destination format */ |
424 | qp = (union rgb_union *)bmpbuf; | 424 | qp = (union rgb_union *)bmpbuf; |
425 | #if LCD_DEPTH > 1 | 425 | #if LCD_DEPTH > 1 |
426 | if (format == FORMAT_NATIVE) { | 426 | if (format == FORMAT_NATIVE) { |
427 | #if LCD_DEPTH == 2 | 427 | #if LCD_DEPTH == 2 |
428 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | 428 | #if LCD_PIXELFORMAT == VERTICAL_PACKING |
429 | /* iriver H1x0 */ | 429 | /* iriver H1x0 */ |
@@ -435,7 +435,8 @@ int read_bmp_file(char* filename, | |||
435 | for (col = 0; col < width; col++) { | 435 | for (col = 0; col < width; col++) { |
436 | if (dither) | 436 | if (dither) |
437 | delta = dither_matrix[row & 0xf][col & 0xf]; | 437 | delta = dither_matrix[row & 0xf][col & 0xf]; |
438 | bright = (257 * (3 * brightness(*qp++) + delta)) >> 16; | 438 | bright = brightness(*qp++); |
439 | bright = (3 * bright + (bright >> 6) + delta) >> 8; | ||
439 | *dest++ |= (~bright & 3) << shift; | 440 | *dest++ |= (~bright & 3) << shift; |
440 | } | 441 | } |
441 | #else /* LCD_PIXELFORMAT == HORIZONTAL_PACKING */ | 442 | #else /* LCD_PIXELFORMAT == HORIZONTAL_PACKING */ |
@@ -449,7 +450,8 @@ int read_bmp_file(char* filename, | |||
449 | for (col = 0; col < width; col++) { | 450 | for (col = 0; col < width; col++) { |
450 | if (dither) | 451 | if (dither) |
451 | delta = dither_matrix[row & 0xf][col & 0xf]; | 452 | delta = dither_matrix[row & 0xf][col & 0xf]; |
452 | bright = (257 * (3 * brightness(*qp++) + delta)) >> 16; | 453 | bright = brightness(*qp++); |
454 | bright = (3 * bright + (bright >> 6) + delta) >> 8; | ||
453 | data |= (~bright & 3) << shift; | 455 | data |= (~bright & 3) << shift; |
454 | shift -= 2; | 456 | shift -= 2; |
455 | if (shift < 0) { | 457 | if (shift < 0) { |
@@ -471,9 +473,9 @@ int read_bmp_file(char* filename, | |||
471 | if (dither) | 473 | if (dither) |
472 | delta = dither_matrix[row & 0xf][col & 0xf]; | 474 | delta = dither_matrix[row & 0xf][col & 0xf]; |
473 | q0 = *qp++; | 475 | q0 = *qp++; |
474 | r = (257 * (31 * q0.red + delta)) >> 16; | 476 | r = (31 * q0.red + (q0.red >> 3) + delta) >> 8; |
475 | g = (257 * (63 * q0.green + delta)) >> 16; | 477 | g = (63 * q0.green + (q0.green >> 2) + delta) >> 8; |
476 | b = (257 * (31 * q0.blue + delta)) >> 16; | 478 | b = (31 * q0.blue + (q0.blue >> 3) + delta) >> 8; |
477 | *dest++ = LCD_RGBPACK_LCD(r, g, b); | 479 | *dest++ = LCD_RGBPACK_LCD(r, g, b); |
478 | } | 480 | } |
479 | #endif /* LCD_DEPTH */ | 481 | #endif /* LCD_DEPTH */ |