1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 2005-04-16 Tomas Salfischberger:
24 - New BMP loader function, based on the old one (borrowed a lot of
25 calculations and checks there.)
26 - Conversion part needs some optimization, doing unneeded calulations now.
27 2006-11-18 Jens Arnold: complete rework
28 - All canonical formats supported now (1, 4, 8, 15/16, 24 and 32 bit)
29 - better protection against malformed / non-standard BMPs
30 - code heavily optimised for both size and speed
31 - dithering for 2 bit targets
32 2008-11-02 Akio Idehara: refactor for scaler frontend
33 2008-12-08 Andrew Mahone: partial-line reading, scaler frontend
34 - read_part_line does the actual source BMP reading, return columns read
35 and updates fields in a struct bmp_args with the new data and current
37 - skip_lines_bmp and store_part_bmp implement the scaler callbacks to skip
38 ahead by whole lines, or read the next chunk of the current line
51 #ifdef HAVE_REMOTE_LCD
52 #include "lcd-remote.h"
54 #ifdef ROCKBOX_DEBUG_BMP_LOADER
55 #define BDEBUGF DEBUGF
70 #define STRUCT_PACKED __attribute__((packed))
73 #pragma pack (push, 2)
76 /* BMP header structure */
78 uint16_t type
; /* signature - 'BM' */
79 uint32_t size
; /* file size in bytes */
80 uint16_t reserved1
; /* 0 */
81 uint16_t reserved2
; /* 0 */
82 uint32_t off_bits
; /* offset to bitmap */
83 uint32_t struct_size
; /* size of this struct (40) */
84 int32_t width
; /* bmap width in pixels */
85 int32_t height
; /* bmap height in pixels */
86 uint16_t planes
; /* num planes - always 1 */
87 uint16_t bit_count
; /* bits per pixel */
88 uint32_t compression
; /* compression flag */
89 uint32_t size_image
; /* image size in bytes */
90 int32_t x_pels_per_meter
; /* horz resolution */
91 int32_t y_pels_per_meter
; /* vert resolution */
92 uint32_t clr_used
; /* 0 -> color table size */
93 uint32_t clr_important
; /* important color count */
97 struct { /* Little endian */
101 unsigned char reserved
;
106 /* masks for supported BI_BITFIELDS encodings (16/32 bit) */
107 static const struct uint8_rgb bitfields
[3][3] = {
110 { .blue
= 0x00, .green
= 0x7c, .red
= 0x00 },
111 { .blue
= 0xe0, .green
= 0x03, .red
= 0x00 },
112 { .blue
= 0x1f, .green
= 0x00, .red
= 0x00 },
116 { .blue
= 0x00, .green
= 0xf8, .red
= 0x00 },
117 { .blue
= 0xe0, .green
= 0x07, .red
= 0x00 },
118 { .blue
= 0x1f, .green
= 0x00, .red
= 0x00 },
122 { .blue
= 0x00, .green
= 0x00, .red
= 0xff },
123 { .blue
= 0x00, .green
= 0xff, .red
= 0x00 },
124 { .blue
= 0xff, .green
= 0x00, .red
= 0x00 },
128 #if (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
129 /* the full 16x16 Bayer dither matrix may be calculated quickly with this table
131 const unsigned char dither_table
[16] =
132 { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 };
135 #if ((LCD_DEPTH == 2) && (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED)) \
136 || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH == 2) \
137 && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED))
138 const unsigned short vi_pattern
[4] = {
139 0x0101, 0x0100, 0x0001, 0x0000
143 /******************************************************************************
146 * Reads a BMP file and puts the data in rockbox format in *bitmap.
148 *****************************************************************************/
149 int read_bmp_file(const char* filename
,
153 const struct custom_format
*cformat
)
156 fd
= open(filename
, O_RDONLY
);
158 /* Exit if file opening failed */
160 DEBUGF("read_bmp_file: can't open '%s', rc: %d\n", filename
, fd
);
164 BDEBUGF("read_bmp_file: '%s' remote: %d resize: %d keep_aspect: %d\n",
165 filename
, !!(format
& FORMAT_REMOTE
), !!(format
& FORMAT_RESIZE
),
166 !!(format
& FORMAT_KEEP_ASPECT
));
167 ret
= read_bmp_fd(fd
, bm
, maxsize
, format
, cformat
);
172 static inline void set_rgb_union(struct uint8_rgb
*dst
, union rgb_union src
)
175 dst
->green
= src
.green
;
176 dst
->blue
= src
.blue
;
185 unsigned char buf
[BM_MAX_WIDTH
* 4];
186 struct uint8_rgb
*palette
;
187 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
188 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
191 struct img_part part
;
195 static unsigned int read_part_line(struct bmp_args
*ba
)
197 const int padded_width
= ba
->padded_width
;
198 const int read_width
= ba
->read_width
;
199 const int width
= ba
->width
;
200 const int depth
= ba
->depth
;
201 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
202 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
203 int cur_row
= ba
->cur_row
;
204 int cur_col
= ba
->cur_col
;
206 const int fd
= ba
->fd
;
208 struct uint8_rgb
*buf
= (struct uint8_rgb
*)(ba
->buf
);
209 const struct uint8_rgb
*palette
= ba
->palette
;
210 uint32_t component
, data
= data
;
214 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
215 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
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
);
218 len
= (cols
* (depth
== 15 ? 16 : depth
) + 7) >> 3;
223 ibuf
= ((unsigned char *)buf
) + (BM_MAX_WIDTH
<< 2) - len
;
224 BDEBUGF("read_part_line: cols=%d len=%d\n",cols
,len
);
225 ret
= read(fd
, ibuf
, len
);
228 DEBUGF("read_part_line: error reading image, read returned %d "
229 "expected %d\n", ret
, len
);
230 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
231 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
232 BDEBUGF("cur_row: %d cur_col: %d cols: %d len: %d\n", cur_row
, cur_col
,
237 while (ibuf
< ba
->buf
+ (BM_MAX_WIDTH
<< 2))
243 for (i
= 0; i
< 8; i
++)
245 *buf
++ = palette
[data
& 0x80 ? 1 : 0];
251 *buf
++ = palette
[data
>> 4];
252 *buf
++ = palette
[data
& 0xf];
255 *buf
++ = palette
[*ibuf
++];
259 data
= letoh16(*(uint16_t*)ibuf
);
260 component
= (data
<< 3) & 0xf8;
261 component
|= component
>> 5;
262 buf
->blue
= component
;
266 component
= data
& 0xf8;
267 component
|= component
>> 5;
270 component
= data
& 0xfc;
271 component
|= component
>> 6;
273 buf
->green
= component
;
275 component
= data
& 0xf8;
276 component
|= component
>> 5;
277 buf
->red
= component
;
284 buf
->green
= *ibuf
++;
293 #if !defined(HAVE_LCD_COLOR) && \
294 ((LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) || \
297 buf
= (struct uint8_rgb
*)ba
->buf
;
298 while (ibuf
< ba
->buf
+ cols
)
299 *ibuf
++ = brightness(*buf
++);
302 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
303 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
305 if (cur_col
== width
)
308 int pad
= padded_width
- read_width
;
311 BDEBUGF("seeking %d bytes to next line\n",pad
);
312 lseek(fd
, pad
, SEEK_CUR
);
314 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
315 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
317 BDEBUGF("read_part_line: completed row %d\n", cur_row
);
321 ba
->cur_row
= cur_row
;
322 ba
->cur_col
= cur_col
;
327 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
328 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
329 static struct img_part
*store_part_bmp(void *args
)
331 struct bmp_args
*ba
= (struct bmp_args
*)args
;
333 ba
->part
.len
= read_part_line(ba
);
334 #ifdef HAVE_LCD_COLOR
335 ba
->part
.buf
= (struct uint8_rgb
*)ba
->buf
;
337 ba
->part
.buf
= (uint8_t *)ba
->buf
;
346 static inline int rgbcmp(struct uint8_rgb rgb1
, struct uint8_rgb rgb2
)
348 if ((rgb1
.red
== rgb2
.red
) && (rgb1
.green
== rgb2
.green
) &&
349 (rgb1
.blue
== rgb2
.blue
))
355 #if !defined(PLUGIN) && !defined(HAVE_JPEG) && !defined(HAVE_BMP_SCALING)
358 void output_row_8_native(uint32_t row
, void * row_in
,
359 struct scaler_context
*ctx
)
362 int fb_width
= BM_WIDTH(ctx
->bm
->width
,FORMAT_NATIVE
,0);
363 uint8_t dy
= DITHERY(row
);
364 #ifdef HAVE_LCD_COLOR
365 struct uint8_rgb
*qp
= (struct uint8_rgb
*)row_in
;
367 uint8_t *qp
= (uint8_t*)row_in
;
369 BDEBUGF("output_row: y: %lu in: %p\n",row
, row_in
);
371 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
372 /* greyscale iPods */
373 fb_data
*dest
= (fb_data
*)ctx
->bm
->data
+ fb_width
* row
;
379 for (col
= 0; col
< ctx
->bm
->width
; col
++) {
381 delta
= DITHERXDY(col
,dy
);
383 bright
= (3 * bright
+ (bright
>> 6) + delta
) >> 8;
384 data
|= (~bright
& 3) << shift
;
394 #elif LCD_PIXELFORMAT == VERTICAL_PACKING
396 fb_data
*dest
= (fb_data
*)ctx
->bm
->data
+ fb_width
*
398 int shift
= 2 * (row
& 3);
402 for (col
= 0; col
< ctx
->bm
->width
; col
++) {
404 delta
= DITHERXDY(col
,dy
);
406 bright
= (3 * bright
+ (bright
>> 6) + delta
) >> 8;
407 *dest
++ |= (~bright
& 3) << shift
;
409 #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED
411 fb_data
*dest
= (fb_data
*)ctx
->bm
->data
+ fb_width
*
417 for (col
= 0; col
< ctx
->bm
->width
; col
++) {
419 delta
= DITHERXDY(col
,dy
);
421 bright
= (3 * bright
+ (bright
>> 6) + delta
) >> 8;
422 *dest
++ |= vi_pattern
[bright
] << shift
;
424 #endif /* LCD_PIXELFORMAT */
425 #elif LCD_DEPTH == 16
426 /* iriver h300, colour iPods, X5 */
427 fb_data
*dest
= (fb_data
*)ctx
->bm
->data
+ fb_width
* row
;
430 for (col
= 0; col
< ctx
->bm
->width
; col
++) {
432 delta
= DITHERXDY(col
,dy
);
436 r
= (31 * r
+ (r
>> 3) + delta
) >> 8;
437 g
= (63 * g
+ (g
>> 2) + delta
) >> 8;
438 b
= (31 * b
+ (b
>> 3) + delta
) >> 8;
439 *dest
++ = LCD_RGBPACK_LCD(r
, g
, b
);
441 #endif /* LCD_DEPTH */
445 /******************************************************************************
448 * Reads a BMP file in an open file descriptor and puts the data in rockbox
451 *****************************************************************************/
452 int read_bmp_fd(int fd
,
456 const struct custom_format
*cformat
)
458 struct bmp_header bmph
;
461 int depth
, numcolors
, compression
, totalsize
;
463 bool return_size
= format
& FORMAT_RETURN_SIZE
;
465 unsigned char *bitmap
= bm
->data
;
466 struct uint8_rgb palette
[256];
469 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) || \
473 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
474 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
475 unsigned int resize
= IMG_NORESIZE
;
476 bool transparent
= false;
478 #ifdef HAVE_REMOTE_LCD
480 if (format
& FORMAT_REMOTE
) {
482 #if LCD_REMOTE_DEPTH == 1
483 format
= FORMAT_MONO
;
486 #endif /* HAVE_REMOTE_LCD */
488 if (format
& FORMAT_RESIZE
) {
492 if (format
& FORMAT_TRANSPARENT
) {
498 #endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/
499 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) || \
501 if (format
& FORMAT_DITHER
) {
505 /* read fileheader */
506 ret
= read(fd
, &bmph
, sizeof(struct bmp_header
));
511 if (ret
!= sizeof(struct bmp_header
)) {
512 DEBUGF("read_bmp_fd: can't read BMP header.");
516 src_dim
.width
= letoh32(bmph
.width
);
517 src_dim
.height
= letoh32(bmph
.height
);
518 if (src_dim
.height
< 0) { /* Top-down BMP file */
519 src_dim
.height
= -src_dim
.height
;
521 } else { /* normal BMP */
525 depth
= letoh16(bmph
.bit_count
);
526 /* 4-byte boundary aligned */
527 read_width
= ((src_dim
.width
* (depth
== 15 ? 16 : depth
) + 7) >> 3);
528 padded_width
= (read_width
+ 3) & ~3;
530 BDEBUGF("width: %d height: %d depth: %d padded_width: %d\n", src_dim
.width
,
531 src_dim
.height
, depth
, padded_width
);
533 #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
534 if ((format
& 3) == FORMAT_ANY
) {
536 format
= (format
& ~3);
538 format
= (format
& ~3) | FORMAT_NATIVE
;
540 bm
->format
= format
& 1;
541 if ((format
& 1) == FORMAT_MONO
)
543 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
544 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
545 resize
&= ~IMG_RESIZE
;
546 resize
|= IMG_NORESIZE
;
548 #ifdef HAVE_REMOTE_LCD
552 #elif !defined(PLUGIN)
553 if (src_dim
.width
> BM_MAX_WIDTH
)
555 #endif /*(LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)*/
557 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
558 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
559 if (resize
& IMG_RESIZE
) {
560 if(format
& FORMAT_KEEP_ASPECT
) {
561 /* keep aspect ratio.. */
562 struct dim resize_dim
= {
564 .height
= bm
->height
,
566 if (recalc_dimension(&resize_dim
, &src_dim
))
567 resize
= IMG_NORESIZE
;
568 bm
->width
= resize_dim
.width
;
569 bm
->height
= resize_dim
.height
;
573 if (!(resize
& IMG_RESIZE
)) {
575 /* returning image size */
576 bm
->width
= src_dim
.width
;
577 bm
->height
= src_dim
.height
;
579 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
580 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
583 #if LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
586 if (rset
.rowstep
> 0) { /* Top-down BMP file */
588 rset
.rowstop
= bm
->height
;
589 } else { /* normal BMP */
590 rset
.rowstart
= bm
->height
- 1;
595 totalsize
= cformat
->get_size(bm
);
597 totalsize
= BM_SIZE(bm
->width
,bm
->height
,format
,remote
);
601 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
602 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
604 totalsize
+= BM_SCALED_SIZE(bm
->width
, 0, 0, 0);
609 /* Check if this fits the buffer */
610 if (totalsize
> maxsize
) {
611 DEBUGF("read_bmp_fd: Bitmap too large for buffer: "
612 "%d bytes.\n", totalsize
);
616 compression
= letoh32(bmph
.compression
);
618 numcolors
= letoh32(bmph
.clr_used
);
620 numcolors
= BIT_N(depth
);
622 numcolors
= (compression
== 3) ? 3 : 0;
624 if (numcolors
> 0 && numcolors
<= 256) {
627 for (i
= 0; i
< numcolors
; i
++) {
628 if (read(fd
, &pal
, sizeof(pal
)) != (int)sizeof(pal
))
630 DEBUGF("read_bmp_fd: Can't read color palette\n");
633 set_rgb_union(&palette
[i
], pal
);
640 /* don't dither 16 bit BMP to LCD with same or larger depth */
641 #ifdef HAVE_REMOTE_LCD
646 if (compression
== 0) { /* BI_RGB, i.e. 15 bit */
649 } /* else fall through */
652 if (compression
== 3) { /* BI_BITFIELDS */
656 /* (i == 0) is 15bit, (i == 1) is 16bit, (i == 2) is 32bit */
657 for (i
= 0; i
< ARRAY_SIZE(bitfields
); i
++) {
658 for (j
= 0; j
< ARRAY_SIZE(bitfields
[0]); j
++) {
659 if (!rgbcmp(palette
[j
], bitfields
[i
][j
])) {
667 if (i
== 0) /* 15bit */
674 } /* else fall through */
677 if (compression
!= 0) { /* not BI_RGB */
678 DEBUGF("read_bmp_fd: Unsupported compression (type %d)\n",
685 /* Search to the beginning of the image data */
686 lseek(fd
, (off_t
)letoh32(bmph
.off_bits
), SEEK_SET
);
688 memset(bitmap
, 0, totalsize
);
690 struct bmp_args ba
= {
691 .fd
= fd
, .padded_width
= padded_width
, .read_width
= read_width
,
692 .width
= src_dim
.width
, .depth
= depth
, .palette
= palette
,
693 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
694 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
695 .cur_row
= 0, .cur_col
= 0, .part
= {0,0}
699 #if (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)) && \
700 defined(HAVE_BMP_SCALING) || defined(PLUGIN)
701 #if LCD_DEPTH > 1 && defined(HAVE_BMP_SCALING)
705 if (resize_on_load(bm
, dither
, &src_dim
, &rset
,
706 bitmap
+ totalsize
, maxsize
- totalsize
,
707 cformat
, IF_PIX_FMT(0,) store_part_bmp
, &ba
))
712 #endif /* LCD_DEPTH */
714 #if LCD_DEPTH > 1 || defined(PLUGIN)
715 struct scaler_context ctx
= {
720 #if defined(PLUGIN) || defined(HAVE_JPEG) || defined(HAVE_BMP_SCALING)
722 void (*output_row_8
)(uint32_t, void*, struct scaler_context
*) =
724 #elif defined(PLUGIN)
725 void (*output_row_8
)(uint32_t, void*, struct scaler_context
*) = NULL
;
727 #if LCD_DEPTH > 1 || defined(PLUGIN)
729 output_row_8
= cformat
->output_row_8
;
734 /* loop to read rows and put them to buffer */
735 for (row
= rset
.rowstart
; row
!= rset
.rowstop
; row
+= rset
.rowstep
) {
736 if (!read_part_line(&ba
))
739 #if !defined(HAVE_LCD_COLOR) && \
740 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1))
741 uint8_t* qp
= ba
.buf
;
743 struct uint8_rgb
*qp
= (struct uint8_rgb
*)ba
.buf
;
746 /* Convert to destination format */
747 #if ((LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) && \
749 if (format
== FORMAT_NATIVE
) {
750 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
752 unsigned char dy
= DITHERY(row
);
753 #if (LCD_REMOTE_DEPTH == 2) && (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED)
754 /* iAudio X5/M5 remote */
755 fb_remote_data
*dest
= (fb_remote_data
*)bitmap
756 + bm
->width
* (row
>> 3);
762 for (col
= 0; col
< bm
->width
; col
++) {
764 delta
= DITHERXDY(col
,dy
);
765 #if !defined(HAVE_LCD_COLOR) && \
766 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1))
769 bright
= brightness(*qp
++);
771 bright
= (3 * bright
+ (bright
>> 6) + delta
) >> 8;
772 *dest
++ |= vi_pattern
[bright
] << shift
;
774 #endif /* LCD_REMOTE_DEPTH / LCD_REMOTE_PIXELFORMAT */
776 #endif /* defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 */
777 #endif /* (LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) &&
778 (LCD_REMOTE_DEPTH > 1) */
779 #if LCD_DEPTH > 1 || defined(PLUGIN)
781 #if !defined(PLUGIN) && !defined(HAVE_JPEG) && !defined(HAVE_BMP_SCALING)
782 output_row_8_native(row
, ba
.buf
, &ctx
);
784 output_row_8(row
, ba
.buf
, &ctx
);
788 #if ((LCD_DEPTH > 1) || defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) && \
797 unsigned char *p
= bitmap
+ bm
->width
* (row
>> 3);
798 unsigned char mask
= BIT_N(row
& 7);
800 for (col
= 0; col
< bm
->width
; col
++, p
++)
801 #if !defined(HAVE_LCD_COLOR) && \
802 (LCD_DEPTH > 1 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1))
806 if (brightness(*qp
++) < 128)
812 return totalsize
; /* return the used buffer size. */