summaryrefslogtreecommitdiff
path: root/apps/recorder/bmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/bmp.c')
-rw-r--r--apps/recorder/bmp.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c
index 26be4e48cf..75165528e7 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -438,7 +438,7 @@ void output_row_8_native(uint32_t row, void * row_in,
438 if (ctx->bm->alpha_offset > 0) 438 if (ctx->bm->alpha_offset > 0)
439 bm_alpha = ctx->bm->data + ctx->bm->alpha_offset; 439 bm_alpha = ctx->bm->data + ctx->bm->alpha_offset;
440 if (bm_alpha) 440 if (bm_alpha)
441 bm_alpha += ctx->bm->width*row/2; 441 bm_alpha += ALIGN_UP(ctx->bm->width, 2) * row/2;
442 442
443 for (col = 0; col < ctx->bm->width; col++) { 443 for (col = 0; col < ctx->bm->width; col++) {
444 if (ctx->dither) 444 if (ctx->dither)
@@ -453,7 +453,7 @@ void output_row_8_native(uint32_t row, void * row_in,
453 dest += STRIDE_MAIN(1, ctx->bm->height); 453 dest += STRIDE_MAIN(1, ctx->bm->height);
454 if (bm_alpha) { 454 if (bm_alpha) {
455 /* pack alpha channel for 2 pixels into 1 byte */ 455 /* pack alpha channel for 2 pixels into 1 byte */
456 unsigned alpha = 255-qp->alpha; 456 unsigned alpha = qp->alpha;
457 if (col%2) 457 if (col%2)
458 *bm_alpha++ |= alpha&0xf0; 458 *bm_alpha++ |= alpha&0xf0;
459 else 459 else
@@ -612,6 +612,8 @@ int read_bmp_fd(int fd,
612 rset.rowstop = -1; 612 rset.rowstop = -1;
613 } 613 }
614 614
615 /* need even rows (see lcd-16bit-common.c for details) */
616 int alphasize = ALIGN_UP(bm->width, 2) * bm->height / 2;
615 if (cformat) 617 if (cformat)
616 totalsize = cformat->get_size(bm); 618 totalsize = cformat->get_size(bm);
617 else { 619 else {
@@ -620,7 +622,7 @@ int read_bmp_fd(int fd,
620 if (!remote) 622 if (!remote)
621#endif 623#endif
622 if (depth == 32 && read_alpha) /* account for possible 4bit alpha per pixel */ 624 if (depth == 32 && read_alpha) /* account for possible 4bit alpha per pixel */
623 totalsize += bm->width * bm->height / 2; 625 totalsize += alphasize;
624 } 626 }
625 627
626 if(return_size) 628 if(return_size)
@@ -718,7 +720,7 @@ int read_bmp_fd(int fd,
718 720
719#ifdef HAVE_LCD_COLOR 721#ifdef HAVE_LCD_COLOR
720 if (read_alpha && depth == 32) 722 if (read_alpha && depth == 32)
721 bm->alpha_offset = totalsize - (bm->width * bm->height / 2); 723 bm->alpha_offset = totalsize - alphasize;
722 else 724 else
723 bm->alpha_offset = 0; 725 bm->alpha_offset = 0;
724#endif 726#endif
@@ -882,7 +884,7 @@ int read_bmp_fd(int fd,
882 { /* if this has an alpha channel, totalsize accounts for it as well 884 { /* if this has an alpha channel, totalsize accounts for it as well
883 * subtract if no actual alpha information was found */ 885 * subtract if no actual alpha information was found */
884 if (bm->alpha_offset > 0) 886 if (bm->alpha_offset > 0)
885 totalsize -= bm->width*bm->height/2; 887 totalsize -= alphasize;
886 bm->alpha_offset = 0; 888 bm->alpha_offset = 0;
887 } 889 }
888#endif 890#endif