All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 6/9] lcd: Support colour lookup table on 16bpp display in BMP images
Date: Wed, 13 May 2015 07:02:28 -0600	[thread overview]
Message-ID: <1431522151-20245-7-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1431522151-20245-1-git-send-email-sjg@chromium.org>

For 16-bit-per-pixel displays it is useful to support 8 bit-per-pixel
images to reduce image size. Add support for this when drawing BMP images.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 common/lcd.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index c7f2830..5a52fe4 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -578,6 +578,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 	unsigned long width, height, byte_width;
 	unsigned long pwidth = panel_info.vl_col;
 	unsigned colors, bpix, bmp_bpix;
+	int hdr_size;
+	struct bmp_color_table_entry *palette = bmp->color_table;
 
 	if (!bmp || !(bmp->header.signature[0] == 'B' &&
 		bmp->header.signature[1] == 'M')) {
@@ -589,6 +591,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 	width = get_unaligned_le32(&bmp->header.width);
 	height = get_unaligned_le32(&bmp->header.height);
 	bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
+	hdr_size = get_unaligned_le16(&bmp->header.size);
+	debug("hdr_size=%d, bmp_bpix=%d\n", hdr_size, bmp_bpix);
 
 	colors = 1 << bmp_bpix;
 
@@ -613,8 +617,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 		return 1;
 	}
 
-	debug("Display-bmp: %d x %d  with %d colors\n",
-		(int)width, (int)height, (int)colors);
+	debug("Display-bmp: %d x %d  with %d colors, display %d\n",
+	      (int)width, (int)height, (int)colors, 1 << bpix);
 
 	if (bmp_bpix == 8)
 		lcd_set_cmap(bmp, colors);
@@ -641,6 +645,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 		cmap_base = configuration_get_cmap();
 #ifdef CONFIG_LCD_BMP_RLE8
 		u32 compression = get_unaligned_le32(&bmp->header.compression);
+		debug("compressed %d %d\n", compression, BMP_BI_RLE8);
 		if (compression == BMP_BI_RLE8) {
 			if (bpix != 16) {
 				/* TODO implement render code for bpix != 16 */
@@ -663,7 +668,19 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 				if (bpix != 16) {
 					fb_put_byte(&fb, &bmap);
 				} else {
-					*(uint16_t *)fb = cmap_base[*(bmap++)];
+					struct bmp_color_table_entry *entry;
+					uint val;
+
+					if (cmap_base) {
+						val = cmap_base[*bmap];
+					} else {
+						entry = &palette[*bmap];
+						val = entry->blue >> 3 |
+							entry->green >> 2 << 5 |
+							entry->red >> 3 << 11;
+					}
+					*(uint16_t *)fb = val;
+					bmap++;
 					fb += sizeof(uint16_t) / sizeof(*fb);
 				}
 			}
-- 
2.2.0.rc0.207.ga3a616c

  parent reply	other threads:[~2015-05-13 13:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13 13:02 [U-Boot] [PATCH v2 0/9] Collected fixes and improvements Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 1/9] dm: usb: Implement usb_detect_change() for driver model Simon Glass
2015-06-11 20:18   ` Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 2/9] arm: spl: Add an API to detect when U-Boot is started from SPL Simon Glass
2015-06-11 20:18   ` Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 3/9] arm: Allow cleanup_before_linux() without disabling caches Simon Glass
2015-06-11 20:18   ` Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 4/9] sandbox: Add an implementation for cleanup_before_linux_select() Simon Glass
2015-06-11 20:19   ` Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 5/9] Remove typedefs from bmp_layout.h Simon Glass
2015-05-13 15:38   ` Joe Hershberger
2015-06-11 20:19     ` Simon Glass
2015-05-13 13:02 ` Simon Glass [this message]
2015-06-11 20:19   ` [U-Boot] [PATCH v2 6/9] lcd: Support colour lookup table on 16bpp display in BMP images Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 7/9] tegra124: Implement spl_was_boot_source() Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 8/9] tegra: nyan-big: Allow TPM on I2C Simon Glass
2015-05-13 13:53   ` Stephen Warren
2015-05-13 13:57     ` Simon Glass
2015-05-13 14:33       ` Stephen Warren
2015-07-03 23:14         ` Simon Glass
2015-05-13 13:02 ` [U-Boot] [PATCH v2 9/9] tegra124: Expand SPL space by 8KB Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431522151-20245-7-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.