Hi everyone,

I maintain a few (commercial) live distributions and have to fulfil the need of a few customers for a nice graphical boot splash. Unfortunately busybox' fbsplash was too unflexible, so I added a bit more configurability:

 * Specify a background color which is used to flood the whole screen
   before drawing the image and the progress bar
 * Specify an x and y offset of the ppm image
 * Specify an x or y offset larger than the respective screen size to
   move the image to the right or bottom edge of the screen (or bottom
   right corner)

The attached patch just re-uses functions already in fbsplash.c and introduces five more config options, this should result in the same size of the busybox binary. Even if these config options are not set, the screen is blanked all black before painting the splash, which might be desired in most cases (and usually is done by using fullscreen images).

With the patch I am able to calculate the position of logo and progress bar by a script before invoking fbsplash and do not have to add a splash for each and every screen resolution. Initially I was thinking about adding more options: color of progess bar and the posibility to specify a gradient, but this might have enlarged the binary which is not desirable.

If you find the patch useful it would be nice you added it.

Yours,
Mattias

--
Mattias Schlenker - Redaktion + EDV-Beratung + Linux-CD/DVD-Konzepte
August-Bebel-Str. 74 - 04275 LEIPZIG - GERMANY

Telefon (VoIP "ueberall"), geschaeftlich: +49 341 39290767
Telefon (Festnetz), privat und Fax:       +49 341 30393578
Mobil:                                    +49 163  6953657

Bitte fuer geschaeftliche Telefonate vorzugsweise die VoIP-Telefonnummer
+49 341 39290767 verwenden, da ich diese aufs Mobiltelefon routen kann!

http://blog.rootserverexperiment.de/ http://news.mattiasschlenker.de/

diff -ru busybox-1.25.0.orig/miscutils/fbsplash.c busybox-1.25.0/miscutils/fbsplash.c
--- busybox-1.25.0.orig/miscutils/fbsplash.c	2016-05-26 19:42:44.000000000 +0200
+++ busybox-1.25.0/miscutils/fbsplash.c	2016-10-01 12:54:38.700436324 +0200
@@ -29,7 +29,8 @@
 //usage:     "\n	-d	Framebuffer device (default /dev/fb0)"
 //usage:     "\n	-i	Config file (var=value):"
 //usage:     "\n			BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT"
-//usage:     "\n			BAR_R,BAR_G,BAR_B"
+//usage:     "\n			BAR_R,BAR_G,BAR_B,IMAGE_LEFT,IMAGE_TOP"
+//usage:     "\n                        BG_R,BG_G,BG_B"
 //usage:     "\n	-f	Control pipe (else exit after drawing image)"
 //usage:     "\n			commands: 'NN' (% for progress bar) or 'exit'"
 
@@ -46,7 +47,7 @@
 	FILE *logfile_fd;	// log file
 #endif
 	unsigned char *addr;	// pointer to framebuffer memory
-	unsigned ns[7];		// n-parameters
+	unsigned ns[12];		// n-parameters
 	const char *image_filename;
 	struct fb_var_screeninfo scr_var;
 	struct fb_fix_screeninfo scr_fix;
@@ -68,6 +69,11 @@
 #define nbar_colr	ns[4]	// progress bar color red component
 #define nbar_colg	ns[5]	// progress bar color green component
 #define nbar_colb	ns[6]	// progress bar color blue component
+#define image_posx	ns[7]	// splash image horizontal position
+#define image_posy	ns[8]	// splash image verical position
+#define flood_colr	ns[9]	// background color red component
+#define flood_colg	ns[10]	// background color green component
+#define flood_colb	ns[11]	// background color blue component
 
 #if DEBUG
 #define DEBUG_MESSAGE(strMessage, args...) \
@@ -340,6 +346,14 @@
 			G.nbar_colr, G.nbar_colg, G.nbar_colb);
 }
 
+/**
+ * Flood the background with one color
+ */
+static void fb_colorfill(void)
+{
+	fb_drawfullrectangle(0, 0, G.scr_var.xres - 1, G.scr_var.yres - 1, 
+		G.flood_colr, G.flood_colg, G.flood_colb);
+}
 
 /**
  * Draw image from PPM file
@@ -398,11 +412,24 @@
 
 	line_size = width*3;
 	pixline = xmalloc(line_size);
-
+	
 	if (width > G.scr_var.xres)
 		width = G.scr_var.xres;
 	if (height > G.scr_var.yres)
 		height = G.scr_var.yres;
+	
+	/* specify a image position outside the visible area to position the splash
+	at the edge of the screen */
+	if (G.image_posx >= G.scr_var.xres)
+		G.image_posx = G.scr_var.xres - width;
+	if (G.image_posy >= G.scr_var.yres)
+		G.image_posy = G.scr_var.yres - width;
+	/* crop the image if upper left corner is within visible area */
+	if (G.image_posx + height > G.scr_var.xres)
+		width = G.image_posx + width - G.scr_var.xres;
+	if (G.image_posy + height > G.scr_var.yres)
+		height = G.image_posy + height - G.scr_var.yres;
+	
 	for (j = 0; j < height; j++) {
 		unsigned char *pixel;
 		unsigned char *src;
@@ -413,7 +440,8 @@
 		src = G.addr + j * G.scr_fix.line_length;
 		for (i = 0; i < width; i++) {
 			unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]);
-			fb_write_pixel(src, thispix);
+			fb_write_pixel(G.image_posy *  G.scr_fix.line_length + 
+				G.image_posx * G.bytes_per_pixel + src, thispix);
 			src += G.bytes_per_pixel;
 			pixel += 3;
 		}
@@ -433,6 +461,8 @@
 		"BAR_WIDTH\0" "BAR_HEIGHT\0"
 		"BAR_LEFT\0" "BAR_TOP\0"
 		"BAR_R\0" "BAR_G\0" "BAR_B\0"
+		"IMAGE_LEFT\0" "IMAGE_TOP\0"
+		"BG_R\0" "BG_G\0" "BG_B\0"
 #if DEBUG
 		"DEBUG\0"
 #endif
@@ -445,10 +475,10 @@
 		int i = index_in_strings(param_names, token[0]);
 		if (i < 0)
 			bb_error_msg_and_die("syntax error: %s", token[0]);
-		if (i >= 0 && i < 7)
+		if (i >= 0 && i < 12)
 			G.ns[i] = val;
 #if DEBUG
-		if (i == 7) {
+		if (i == 12) {
 			G.bdebug_messages = val;
 			if (G.bdebug_messages)
 				G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log");
@@ -492,6 +522,7 @@
 		full_write(STDOUT_FILENO, "\033[?25l", 6);
 	}
 
+	fb_colorfill(); 
 	fb_drawimage();
 
 	if (!fifo_filename)
diff -ru busybox-1.25.0.orig/miscutils/fbsplash.cfg busybox-1.25.0/miscutils/fbsplash.cfg
--- busybox-1.25.0.orig/miscutils/fbsplash.cfg	2015-07-13 04:18:47.000000000 +0200
+++ busybox-1.25.0/miscutils/fbsplash.cfg	2016-10-01 12:59:17.905354352 +0200
@@ -1,9 +1,16 @@
 # progress bar position
 BAR_LEFT=170
-BAR_TOP=300
+BAR_TOP=400
 BAR_WIDTH=300
 BAR_HEIGHT=20
 # progress bar color
 BAR_R=80
 BAR_G=80
 BAR_B=130
+# image position
+IMAGE_LEFT=100
+IMAGE_TOP=100
+# background
+BG_R=80
+BG_G=130
+BG_B=80

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to