mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] gui: bmp: add support for alpha channel
@ 2025-06-01 12:15 Ahmad Fatoum
  2025-06-02  7:52 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-06-01 12:15 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Apparently, 32-bit bitmaps are a thing and at least Debian Bookworm's
ImageMagick 6.9.11-60 generates them by default, unless
-alpha deactivate is passed to convert.

We don't pass that and thus barebox complains when asked to display them:

  barebox@STM32MP157C-DK2:/ splash /logo/barebox-logo-64.bmp
  bmp: illegal bits per pixel value: 32

As we already have alpha blending support in use for PNG and QOI, just
have the bitmap parser make use of it as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 lib/gui/bmp.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/gui/bmp.c b/lib/gui/bmp.c
index bbc623dba329..6eea337cd004 100644
--- a/lib/gui/bmp.c
+++ b/lib/gui/bmp.c
@@ -96,7 +96,7 @@ static int bmp_renderer(struct screen *sc, struct surface *s, struct image *img)
 				image += bits_per_pixel >> 3;
 			}
 		}
-	} else if (bits_per_pixel == 24) {
+	} else if (bits_per_pixel == 24 || bits_per_pixel == 32) {
 		int x, y;
 
 		for (y = 0; y < height; y++) {
@@ -106,12 +106,11 @@ static int bmp_renderer(struct screen *sc, struct surface *s, struct image *img)
 			adr = buf + (y + starty) * sc->info->line_length +
 					startx * (sc->info->bits_per_pixel >> 3);
 			for (x = 0; x < width; x++) {
-				char *pixel;
+				u8 *pixel = image;
+				u8 alpha = bits_per_pixel == 32 ? pixel[3] : 255;
 
-				pixel = image;
-
-				gu_set_rgb_pixel(sc->info, adr, pixel[2], pixel[1],
-						pixel[0]);
+				gu_set_rgba_pixel(sc->info, adr,
+						  pixel[2], pixel[1], pixel[0], alpha);
 				adr += sc->info->bits_per_pixel >> 3;
 
 				image += bits_per_pixel >> 3;
-- 
2.39.5




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gui: bmp: add support for alpha channel
  2025-06-01 12:15 [PATCH] gui: bmp: add support for alpha channel Ahmad Fatoum
@ 2025-06-02  7:52 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-06-02  7:52 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Sun, 01 Jun 2025 14:15:51 +0200, Ahmad Fatoum wrote:
> Apparently, 32-bit bitmaps are a thing and at least Debian Bookworm's
> ImageMagick 6.9.11-60 generates them by default, unless
> -alpha deactivate is passed to convert.
> 
> We don't pass that and thus barebox complains when asked to display them:
> 
>   barebox@STM32MP157C-DK2:/ splash /logo/barebox-logo-64.bmp
>   bmp: illegal bits per pixel value: 32
> 
> [...]

Applied, thanks!

[1/1] gui: bmp: add support for alpha channel
      https://git.pengutronix.de/cgit/barebox/commit/?id=0034d4ba36d0 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-02  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-01 12:15 [PATCH] gui: bmp: add support for alpha channel Ahmad Fatoum
2025-06-02  7:52 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox