diff options
Diffstat (limited to 'core/modules/busybox/fbsplash-center.patch')
-rw-r--r-- | core/modules/busybox/fbsplash-center.patch | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/core/modules/busybox/fbsplash-center.patch b/core/modules/busybox/fbsplash-center.patch new file mode 100644 index 00000000..748420fd --- /dev/null +++ b/core/modules/busybox/fbsplash-center.patch @@ -0,0 +1,85 @@ +diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c +index 7b695b2..e3a55ca 100644 +--- a/miscutils/fbsplash.c ++++ b/miscutils/fbsplash.c +@@ -9,6 +9,7 @@ + * - put somewhere fbsplash.cfg file and an image in .ppm format. + * - run applet: $ setsid fbsplash [params] & + * -c: hide cursor ++ * -x: center image (if smaller than screen) + * -d /dev/fbN: framebuffer device (if not /dev/fb0) + * -s path_to_image_file (can be "-" for stdin) + * -i path_to_cfg_file +@@ -22,10 +23,11 @@ + */ + + //usage:#define fbsplash_trivial_usage +-//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]" ++//usage: "-s IMGFILE [-c] [-x] [-d DEV] [-i INIFILE] [-f CMD]" + //usage:#define fbsplash_full_usage "\n\n" + //usage: " -s Image" + //usage: "\n -c Hide cursor" ++//usage: "\n -x Center image (if smaller than screen)" + //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" +@@ -54,6 +56,7 @@ struct globals { + unsigned red_shift; + unsigned green_shift; + unsigned blue_shift; ++ bool bcenter_image; + }; + #define G (*ptr_to_globals) + #define INIT_G() do { \ +@@ -349,6 +352,8 @@ static void fb_drawimage(void) + char *read_ptr; + unsigned char *pixline; + unsigned i, j, width, height, line_size; ++ int xoffset = 0; ++ int yoffset = 0; + + if (LONE_DASH(G.image_filename)) { + theme_file = stdin; +@@ -396,6 +401,13 @@ static void fb_drawimage(void) + line_size = width*3; + pixline = xmalloc(line_size); + ++ if (G.bcenter_image) { ++ if (width < G.scr_var.xres) ++ xoffset = ((G.scr_var.xres - width) / 2) * G.bytes_per_pixel; ++ if (height < G.scr_var.yres) ++ yoffset = (G.scr_var.yres - height) / 2; ++ } ++ + if (width > G.scr_var.xres) + width = G.scr_var.xres; + if (height > G.scr_var.yres) +@@ -407,7 +419,7 @@ static void fb_drawimage(void) + if (fread(pixline, 1, line_size, theme_file) != line_size) + bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); + pixel = pixline; +- src = G.addr + j * G.scr_fix.line_length; ++ src = G.addr + (j + yoffset) * G.scr_fix.line_length + xoffset; + for (i = 0; i < width; i++) { + unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]); + fb_write_pixel(src, thispix); +@@ -463,6 +475,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + FILE *fp = fp; // for compiler + char *num_buf; + unsigned num; ++ unsigned optret; + bool bCursorOff; + + INIT_G(); +@@ -471,8 +484,10 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + fb_device = "/dev/fb0"; + cfg_filename = NULL; + fifo_filename = NULL; +- bCursorOff = 1 & getopt32(argv, "cs:d:i:f:", ++ optret = getopt32(argv, "cxs:d:i:f:", + &G.image_filename, &fb_device, &cfg_filename, &fifo_filename); ++ bCursorOff = 1 & optret; ++ G.bcenter_image = 2 & optret; + + // parse configuration file + if (cfg_filename) |