mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@kalray.eu>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH 4/5] logo: Enable image format selection for the logo
Date: Mon, 10 Jan 2022 23:12:54 +0100	[thread overview]
Message-ID: <20220110221255.5003-5-jmaselbas@kalray.eu> (raw)
In-Reply-To: <20220110221255.5003-1-jmaselbas@kalray.eu>

Enables the selection of an image format to be used for the built-in
barebox logo. The default image format is set to png, has it was the
only choice before. This also adds bmp as the other option.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 lib/logo/Kconfig  | 20 +++++++++++++++++++-
 lib/logo/Makefile | 43 ++++++++++++++++++++++++++++++-------------
 lib/logo/logo.c   |  8 +++++++-
 3 files changed, 56 insertions(+), 15 deletions(-)

diff --git a/lib/logo/Kconfig b/lib/logo/Kconfig
index 7d55f7fa27..8edfaaeb51 100644
--- a/lib/logo/Kconfig
+++ b/lib/logo/Kconfig
@@ -3,10 +3,28 @@ menuconfig BAREBOX_LOGO
 	help
 	  Say yes here to build the barebox logos. This adds ImageMagick's
 	  convert tool to the build dependencies. The logo can be found under
-	  /logo/barebox-logo-<width>.png in the running barebox.
+	  /logo/barebox-logo-<width>.<ext> in the running barebox.
 
 if BAREBOX_LOGO
 
+choice
+	prompt "Logo image encoding format to be used"
+	default BAREBOX_LOGO_PNG
+
+config BAREBOX_LOGO_PNG
+	bool "png"
+	select PNG
+	help
+	  Encode logo with the PNG image format
+
+config BAREBOX_LOGO_BMP
+	bool "bmp"
+	select BMP
+	help
+	  Encode logo with the BMP image format
+
+endchoice
+
 config BAREBOX_LOGO_64
 	bool "include 64x32 pixel logo"
 
diff --git a/lib/logo/Makefile b/lib/logo/Makefile
index f08beef76b..04c4906838 100644
--- a/lib/logo/Makefile
+++ b/lib/logo/Makefile
@@ -1,17 +1,17 @@
 
-OPTS_barebox-logo-w64.bblogo = -resize 64
+OPTS_barebox-logo-w64 = -resize 64
 bblogo-$(CONFIG_BAREBOX_LOGO_64) += barebox-logo-w64
 
-OPTS_barebox-logo-w240.bblogo = -resize 240
+OPTS_barebox-logo-w240 = -resize 240
 bblogo-$(CONFIG_BAREBOX_LOGO_240) += barebox-logo-w240
 
-OPTS_barebox-logo-w320.bblogo = -resize 320
+OPTS_barebox-logo-w320 = -resize 320
 bblogo-$(CONFIG_BAREBOX_LOGO_320) += barebox-logo-w320
 
-OPTS_barebox-logo-w400.bblogo = -resize 400
+OPTS_barebox-logo-w400 = -resize 400
 bblogo-$(CONFIG_BAREBOX_LOGO_400) += barebox-logo-w400
 
-OPTS_barebox-logo-w640.bblogo = -resize 640
+OPTS_barebox-logo-w640 = -resize 640
 bblogo-$(CONFIG_BAREBOX_LOGO_640) += barebox-logo-w640
 
 obj-y += $(patsubst %,%.bblogo.o,$(bblogo-y))
@@ -38,15 +38,32 @@ cmd_logo_S =							\
 %.bblogo.S: %.bblogo FORCE
 	$(call if_changed,logo_S)
 
+quiet_cmd_logo = LOGO     $@
+      cmd_logo = cp $< $@
+
+ifdef CONFIG_BAREBOX_LOGO_PNG
+extra-y += $(patsubst %,%.png,$(bblogo-y))
+%.bblogo: %.png FORCE
+	$(call if_changed,logo)
+endif
+ifdef CONFIG_BAREBOX_LOGO_BMP
+extra-y += $(patsubst %,%.bmp,$(bblogo-y))
+%.bblogo: %.bmp FORCE
+	$(call if_changed,logo)
+endif
+
 CONVERTOPTS += -background none
 
-quiet_cmd_logo = PNG     $@
-cmd_logo =							\
-(								\
-	convert $(OPTS_$(@F)) $(CONVERTOPTS) $< png:$@; \
-)
+quiet_cmd_bmp = BMP     $@
+      cmd_bmp = convert $(OPTS_$(@F:.bmp=)) $(CONVERTOPTS) $< bmp:$@
 
-%.bblogo: $(srctree)/Documentation/barebox.svg FORCE
-	$(call if_changed,logo)
+%.bmp: $(srctree)/Documentation/barebox.svg FORCE
+	$(call if_changed,bmp)
+
+quiet_cmd_png = PNG     $@
+      cmd_png =	convert $(OPTS_$(@F:.png=)) $(CONVERTOPTS) $< png:$@
+
+%.png: $(srctree)/Documentation/barebox.svg FORCE
+	$(call if_changed,png)
 
-clean-files += *.bblogo *.bblogo.S
+clean-files += *.png *.bmp *.bblogo *.bblogo.S
diff --git a/lib/logo/logo.c b/lib/logo/logo.c
index 8349b060ac..200eb992b3 100644
--- a/lib/logo/logo.c
+++ b/lib/logo/logo.c
@@ -32,8 +32,14 @@ static void load_logo(int width, void *start, void *end)
 {
 	char *filename;
 	size_t size = end - start;
+	char *ext = "";
 
-	filename = basprintf("/logo/barebox-logo-%d.png", width);
+	if (IS_ENABLED(CONFIG_BAREBOX_LOGO_PNG))
+		ext = "png";
+	else if (IS_ENABLED(CONFIG_BAREBOX_LOGO_BMP))
+		ext = "bmp";
+
+	filename = basprintf("/logo/barebox-logo-%d.%s", width, ext);
 	write_file(filename, start, size);
 	free(filename);
 }
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2022-01-10 22:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 22:12 [PATCH 0/5] Add support for QOI image format Jules Maselbas
2022-01-10 22:12 ` [PATCH 1/5] filetype: Add QOI format image type Jules Maselbas
2022-01-14  9:00   ` Ahmad Fatoum
2022-01-10 22:12 ` [PATCH 2/5] gui: Add qoi image format Jules Maselbas
2022-01-14 10:05   ` Ahmad Fatoum
2022-01-14 10:54     ` Jules Maselbas
2022-01-10 22:12 ` [PATCH 3/5] scripts: Add qoiconv to convert png to qoi Jules Maselbas
2022-01-14 10:29   ` Ahmad Fatoum
2022-01-14 11:14     ` Jules Maselbas
2022-01-17 11:48       ` Ahmad Fatoum
2022-01-10 22:12 ` Jules Maselbas [this message]
2022-01-10 22:12 ` [PATCH 5/5] logo: Add choice for the QOI image format option Jules Maselbas
2022-01-14 10:28 ` [PATCH 0/5] Add support for QOI image format Ahmad Fatoum

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=20220110221255.5003-5-jmaselbas@kalray.eu \
    --to=jmaselbas@kalray.eu \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox