static void splash_align_axis(int *axis, unsigned long panel_size,
unsigned long picture_size)
{
- unsigned long panel_picture_delta = panel_size - picture_size;
- unsigned long axis_alignment;
+ int panel_picture_delta = panel_size - picture_size;
+ int axis_alignment;
if (*axis == BMP_ALIGN_CENTER)
axis_alignment = panel_picture_delta / 2;
+ else if (abs(*axis) > (int)panel_size)
+ axis_alignment = panel_size;
else if (*axis < 0)
axis_alignment = panel_picture_delta + *axis + 1;
else
return;
-
- *axis = max(0, (int)axis_alignment);
+ *axis = axis_alignment;
}
#endif
hdr_size = get_unaligned_le16(&bmp->header.size);
debug("hdr_size=%d, bmp_bpix=%d\n", hdr_size, bmp_bpix);
- colors = 1 << bmp_bpix;
+ colors = 1ULL << bmp_bpix;
bpix = NBITS(panel_info.vl_bpix);
* We support displaying 8bpp BMPs on 16bpp LCDs
* and displaying 24bpp BMPs on 32bpp LCDs
* */
- if (bpix != bmp_bpix &&
- !(bmp_bpix == 8 && bpix == 16) &&
- !(bmp_bpix == 24 && bpix == 32)) {
+ if (bpix < bmp_bpix) {
printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
bpix, get_unaligned_le16(&bmp->header.bit_count));
return 1;
}
- debug("Display-bmp: %lu x %lu with %llu colors, display %d\n",
- width, height, colors, NBITS(bmp_bpix));
+ debug("Display-bmp: %lu x %lu with %llu colors, display %llu\n",
+ width, height, colors, 1ULL << bpix);
if (bmp_bpix == 8)
lcd_set_cmap(bmp, colors);
#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
- if ((x + width) > pwidth)
+ if (x < 0) {
+ width += x;
+ bmap += -x * bmp_bpix / 8;
+ x = 0;
+ }
+ if ((x + width) > pwidth) {
width = pwidth - x;
+ }
+ if (y < 0) {
+ height += y;
+ y = 0;
+ }
if ((y + height) > panel_info.vl_row) {
+ bmap += (y + height - panel_info.vl_row) * bmp_bpix / 8 * padded_width;
height = panel_info.vl_row - y;
- bmap += (panel_info.vl_row - y) * padded_width;
}
fb = (uchar *)(lcd_base +
for (i = 0; i < height; ++i) {
WATCHDOG_RESET();
for (j = 0; j < width; j++) {
- if (bpix != 16) {
+ if (bpix == 8) {
fb_put_byte(&fb, &bmap);
- } else {
+ } else if (bpix == 16) {
struct bmp_color_table_entry *entry;
uint val;
entry->red >> 3 << 11;
}
*(uint16_t *)fb = val;
- bmap++;
fb += sizeof(uint16_t) / sizeof(*fb);
+ } else if (bpix == 32) {
+ uint32_t *fb32 = (uint32_t *)fb;
+ struct bmp_color_table_entry *entry;
+ uint val;
+
+ if (cmap_base) {
+ val = cmap_base[*bmap];
+ } else {
+ entry = &palette[*bmap];
+ val = entry->blue |
+ entry->green << 8 |
+ entry->red << 16;
+ }
+ *fb32 = val;
+ fb += sizeof(uint32_t) / sizeof(*fb);
}
+ bmap++;
}
- if (bpix > 8) {
- bmap += padded_width - width;
- fb -= width * bpix / 8 + lcd_line_length;
- } else {
- bmap += padded_width;
- fb -= lcd_line_length;
- }
+ bmap += padded_width - width;
+ fb -= width * bpix / 8 + lcd_line_length;
}
break;
}
}
break;
#endif /* CONFIG_BMP_16BPP */
-#if defined(CONFIG_BMP_24BMP)
+#if defined(CONFIG_BMP_24BPP)
case 24:
for (i = 0; i < height; ++i) {
for (j = 0; j < width; j++) {
*(fb++) = *(bmap++);
*(fb++) = 0;
}
+ bmap += (padded_width - width) * 3;
fb -= lcd_line_length + width * (bpix / 8);
}
break;
}
break;
#endif /* CONFIG_BMP_32BPP */
+ default:
+ printf("Logo with %ubpp on %ubpp display not supported\n",
+ bmp_bpix, bpix);
};
lcd_sync();