#endif
#endif /* CONFIG_BMP_16BPP */
+static inline bmp_color_table_entry_t *get_color_table(bmp_image_t *bmp)
+{
+ bmp_header_t *bh = &bmp->header;
+ return (void *)bmp + offsetof(bmp_header_t, size) + bh->size;
+}
+
int lcd_display_bitmap(ulong bmp_image, int x, int y)
{
#if !defined(CONFIG_MCC200)
unsigned long pwidth = panel_info.vl_col;
unsigned long long colors;
unsigned bpix, bmp_bpix;
+ bmp_color_table_entry_t *cte;
if (!bmp || !(bmp->header.signature[0] == 'B' &&
bmp->header.signature[1] == 'M')) {
debug("Display-bmp: %lu x %lu with %llu colors\n",
width, height, colors);
+ cte = get_color_table(bmp);
#if !defined(CONFIG_MCC200)
/* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
if (bmp_bpix == 8) {
/* Set color map */
for (i = 0; i < colors; ++i) {
- bmp_color_table_entry_t cte = bmp->color_table[i];
#if !defined(CONFIG_ATMEL_LCD)
ushort colreg =
- ( ((cte.red) << 8) & 0xf800) |
- ( ((cte.green) << 3) & 0x07e0) |
- ( ((cte.blue) >> 3) & 0x001f) ;
+ ( ((cte[i].red) << 8) & 0xf800) |
+ ( ((cte[i].green) << 3) & 0x07e0) |
+ ( ((cte[i].blue) >> 3) & 0x001f) ;
#ifdef CONFIG_SYS_INVERT_COLORS
*cmap = 0xffff - colreg;
#else
cmap++;
#endif
#else /* CONFIG_ATMEL_LCD */
- lcd_setcolreg(i, cte.red, cte.green, cte.blue);
+ lcd_setcolreg(i, cte[i].red, cte[i].green, cte[i].blue);
#endif
}
}
splash_align_axis(&x, pwidth, width);
splash_align_axis(&y, panel_info.vl_row, height);
#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
- bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
+ bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset);
if ((x + width) > pwidth)
- width = max(pwidth - x, pwidth);
+ width = pwidth - x;
if ((y + height) > panel_info.vl_row) {
height = panel_info.vl_row - y;
bmap += (panel_info.vl_row - y) * padded_width;
}
- bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset);
fb = (uchar *)(lcd_base +
(y + height - 1) * lcd_line_length + x * bpix / 8);
int i = *bmap++;
fb[3] = 0; /* T */
- fb[0] = bmp->color_table[i].blue;
- fb[1] = bmp->color_table[i].green;
- fb[2] = bmp->color_table[i].red;
+ fb[0] = cte[i].blue;
+ fb[1] = cte[i].green;
+ fb[2] = cte[i].red;
fb += sizeof(uint32_t) / sizeof(*fb);
} else if (bpix == 16) {
*(uint16_t *)fb = cmap_base[*(bmap++)];
FB_PUT_BYTE(fb, bmap);
}
}
- bmap += padded_width - width;
- fb -= width + lcd_line_length;
+ if (bpix > 8) {
+ bmap += padded_width - width;
+ fb -= width * bpix / 8 + lcd_line_length;
+ } else {
+ bmap += padded_width;
+ fb -= lcd_line_length;
+ }
}
break;