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.c86
1 files changed, 47 insertions, 39 deletions
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c
index 3fb8a4d6c1..403c34d951 100644
--- a/apps/recorder/bmp.c
+++ b/apps/recorder/bmp.c
@@ -184,8 +184,8 @@ struct bmp_args {
184 short depth; 184 short depth;
185 unsigned char buf[BM_MAX_WIDTH * 4]; 185 unsigned char buf[BM_MAX_WIDTH * 4];
186 struct uint8_rgb *palette; 186 struct uint8_rgb *palette;
187#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 187#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
188 defined(PLUGIN) 188 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
189 int cur_row; 189 int cur_row;
190 int cur_col; 190 int cur_col;
191 struct img_part part; 191 struct img_part part;
@@ -198,8 +198,8 @@ static unsigned int read_part_line(struct bmp_args *ba)
198 const int read_width = ba->read_width; 198 const int read_width = ba->read_width;
199 const int width = ba->width; 199 const int width = ba->width;
200 const int depth = ba->depth; 200 const int depth = ba->depth;
201#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 201#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
202 defined(PLUGIN) 202 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
203 int cur_row = ba->cur_row; 203 int cur_row = ba->cur_row;
204 int cur_col = ba->cur_col; 204 int cur_col = ba->cur_col;
205#endif 205#endif
@@ -211,8 +211,8 @@ static unsigned int read_part_line(struct bmp_args *ba)
211 int ret; 211 int ret;
212 int i, cols, len; 212 int i, cols, len;
213 213
214#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) || \ 214#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
215 defined(PLUGIN) 215 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
216 cols = MIN(width - cur_col,(int)BM_MAX_WIDTH); 216 cols = MIN(width - cur_col,(int)BM_MAX_WIDTH);
217 BDEBUGF("reading %d cols (width: %d, max: %d)\n",cols,width,BM_MAX_WIDTH); 217 BDEBUGF("reading %d cols (width: %d, max: %d)\n",cols,width,BM_MAX_WIDTH);
218 len = (cols * (depth == 15 ? 16 : depth) + 7) >> 3; 218 len = (cols * (depth == 15 ? 16 : depth) + 7) >> 3;
@@ -227,8 +227,8 @@ static unsigned int read_part_line(struct bmp_args *ba)
227 { 227 {
228 DEBUGF("read_part_line: error reading image, read returned %d " 228 DEBUGF("read_part_line: error reading image, read returned %d "
229 "expected %d\n", ret, len); 229 "expected %d\n", ret, len);
230#if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) || \ 230#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
231 defined(PLUGIN) 231 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
232 BDEBUGF("cur_row: %d cur_col: %d cols: %d len: %d\n", cur_row, cur_col, 232 BDEBUGF("cur_row: %d cur_col: %d cols: %d len: %d\n", cur_row, cur_col,
233 cols, len); 233 cols, len);
234#endif 234#endif
@@ -290,17 +290,17 @@ static unsigned int read_part_line(struct bmp_args *ba)
290 } 290 }
291 } 291 }
292 292
293#if (!defined(HAVE_LCD_COLOR) && \ 293#if !defined(HAVE_LCD_COLOR) && \
294 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1))) || \ 294 ((LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) || \
295 defined(PLUGIN) 295 defined(PLUGIN))
296 ibuf = ba->buf; 296 ibuf = ba->buf;
297 buf = (struct uint8_rgb*)ba->buf; 297 buf = (struct uint8_rgb*)ba->buf;
298 while (ibuf < ba->buf + cols) 298 while (ibuf < ba->buf + cols)
299 *ibuf++ = brightness(*buf++); 299 *ibuf++ = brightness(*buf++);
300#endif 300#endif
301 301
302#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 302#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
303 defined(PLUGIN) 303 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
304 cur_col += cols; 304 cur_col += cols;
305 if (cur_col == width) 305 if (cur_col == width)
306 { 306 {
@@ -311,8 +311,8 @@ static unsigned int read_part_line(struct bmp_args *ba)
311 BDEBUGF("seeking %d bytes to next line\n",pad); 311 BDEBUGF("seeking %d bytes to next line\n",pad);
312 lseek(fd, pad, SEEK_CUR); 312 lseek(fd, pad, SEEK_CUR);
313 } 313 }
314#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 314#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
315 defined(PLUGIN) 315 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
316 cur_col = 0; 316 cur_col = 0;
317 BDEBUGF("read_part_line: completed row %d\n", cur_row); 317 BDEBUGF("read_part_line: completed row %d\n", cur_row);
318 cur_row += 1; 318 cur_row += 1;
@@ -324,8 +324,8 @@ static unsigned int read_part_line(struct bmp_args *ba)
324 return cols; 324 return cols;
325} 325}
326 326
327#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 327#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
328 defined(PLUGIN) 328 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
329static struct img_part *store_part_bmp(void *args) 329static struct img_part *store_part_bmp(void *args)
330{ 330{
331 struct bmp_args *ba = (struct bmp_args *)args; 331 struct bmp_args *ba = (struct bmp_args *)args;
@@ -375,10 +375,13 @@ int read_bmp_fd(int fd,
375 struct uint8_rgb palette[256]; 375 struct uint8_rgb palette[256];
376 struct rowset rset; 376 struct rowset rset;
377 struct dim src_dim; 377 struct dim src_dim;
378#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) \ 378#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) || \
379 || defined(PLUGIN) 379 defined(PLUGIN)
380 unsigned int resize = IMG_NORESIZE;
381 bool dither = false; 380 bool dither = false;
381#endif
382#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
383 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
384 unsigned int resize = IMG_NORESIZE;
382 bool transparent = false; 385 bool transparent = false;
383 386
384#ifdef HAVE_REMOTE_LCD 387#ifdef HAVE_REMOTE_LCD
@@ -398,14 +401,16 @@ int read_bmp_fd(int fd,
398 if (format & FORMAT_TRANSPARENT) { 401 if (format & FORMAT_TRANSPARENT) {
399 transparent = true; 402 transparent = true;
400 } 403 }
401 if (format & FORMAT_DITHER) {
402 dither = true;
403 }
404#else 404#else
405 405
406 (void)format; 406 (void)format;
407#endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/ 407#endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/
408 408#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) || \
409 defined(PLUGIN)
410 if (format & FORMAT_DITHER) {
411 dither = true;
412 }
413#endif
409 /* read fileheader */ 414 /* read fileheader */
410 ret = read(fd, &bmph, sizeof(struct bmp_header)); 415 ret = read(fd, &bmph, sizeof(struct bmp_header));
411 if (ret < 0) { 416 if (ret < 0) {
@@ -444,8 +449,11 @@ int read_bmp_fd(int fd,
444 bm->format = format & 1; 449 bm->format = format & 1;
445 if ((format & 1) == FORMAT_MONO) 450 if ((format & 1) == FORMAT_MONO)
446 { 451 {
452#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
453 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
447 resize &= ~IMG_RESIZE; 454 resize &= ~IMG_RESIZE;
448 resize |= IMG_NORESIZE; 455 resize |= IMG_NORESIZE;
456#endif
449#ifdef HAVE_REMOTE_LCD 457#ifdef HAVE_REMOTE_LCD
450 remote = 0; 458 remote = 0;
451#endif 459#endif
@@ -455,8 +463,8 @@ int read_bmp_fd(int fd,
455 return -6; 463 return -6;
456#endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/ 464#endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/
457 465
458#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 466#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
459 defined(PLUGIN) 467 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
460 if (resize & IMG_RESIZE) { 468 if (resize & IMG_RESIZE) {
461 if(format & FORMAT_KEEP_ASPECT) { 469 if(format & FORMAT_KEEP_ASPECT) {
462 /* keep aspect ratio.. */ 470 /* keep aspect ratio.. */
@@ -471,19 +479,19 @@ int read_bmp_fd(int fd,
471 } 479 }
472 } 480 }
473 481
474 format &= 1;
475
476 if (!(resize & IMG_RESIZE)) { 482 if (!(resize & IMG_RESIZE)) {
477#endif 483#endif
478 /* returning image size */ 484 /* returning image size */
479 bm->width = src_dim.width; 485 bm->width = src_dim.width;
480 bm->height = src_dim.height; 486 bm->height = src_dim.height;
481 487
482#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 488#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
483 defined(PLUGIN) 489 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
484 } 490 }
485#endif 491#endif
486 492#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
493 format &= 1;
494#endif
487 if (rset.rowstep > 0) { /* Top-down BMP file */ 495 if (rset.rowstep > 0) { /* Top-down BMP file */
488 rset.rowstart = 0; 496 rset.rowstart = 0;
489 rset.rowstop = bm->height; 497 rset.rowstop = bm->height;
@@ -581,15 +589,15 @@ int read_bmp_fd(int fd,
581 struct bmp_args ba = { 589 struct bmp_args ba = {
582 .fd = fd, .padded_width = padded_width, .read_width = read_width, 590 .fd = fd, .padded_width = padded_width, .read_width = read_width,
583 .width = src_dim.width, .depth = depth, .palette = palette, 591 .width = src_dim.width, .depth = depth, .palette = palette,
584#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 592#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
585 defined(PLUGIN) 593 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
586 .cur_row = 0, .cur_col = 0, .part = {0,0} 594 .cur_row = 0, .cur_col = 0, .part = {0,0}
587#endif 595#endif
588 }; 596 };
589 597
590#if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) || \ 598#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
591 defined(PLUGIN) 599 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
592#if LCD_DEPTH > 1 600#if LCD_DEPTH > 1 && defined(HAVE_BMP_SCALING)
593 if (resize || cformat) 601 if (resize || cformat)
594#endif 602#endif
595 { 603 {
@@ -600,12 +608,12 @@ int read_bmp_fd(int fd,
600 else 608 else
601 return 0; 609 return 0;
602 } 610 }
603#ifndef PLUGIN
604 int fb_width = BM_WIDTH(bm->width,bm->format,remote);
605#endif
606#endif /* LCD_DEPTH */ 611#endif /* LCD_DEPTH */
607 612
608#ifndef PLUGIN 613#ifndef PLUGIN
614#if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1))
615 int fb_width = BM_WIDTH(bm->width,bm->format,remote);
616#endif
609 int col, row; 617 int col, row;
610 618
611 /* loop to read rows and put them to buffer */ 619 /* loop to read rows and put them to buffer */