aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorPeter Korsgaard <peter@korsgaard.com>2018-03-29 13:35:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-03-29 18:42:11 +0200
commita82fe671f5c7ff96ca4d4d813210d18e0b02c193 (patch)
tree1a3575edf3de626a9271fa7c10d1fcdf800cb7a3 /miscutils
parent03fd7e06f854d385070a6fc9714f445727c359cd (diff)
downloadbusybox-a82fe671f5c7ff96ca4d4d813210d18e0b02c193.tar.gz
fbsplash: support configurable image position
For some setups (E.G. for supporting different screen resolutions), positioning the image somewhere else than the top left corner may be interesting. Add support for IMG_LEFT/IMG_TOP settings to specify the image location, similar to how it is done for the progress bar. function old new delta fbsplash_main 994 1038 +44 static.param_names 57 74 +17 packed_usage 32631 32647 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 77/0) Total: 77 bytes Signed-off-by: Peter Korsgaard <peter@korsgaard.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/fbsplash.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 5b2e5ac56..bc3c61055 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -54,7 +54,7 @@
//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,IMG_LEFT,IMG_TOP"
//usage: "\n -f Control pipe (else exit after drawing image)"
//usage: "\n commands: 'NN' (% for progress bar) or 'exit'"
@@ -73,7 +73,7 @@ struct globals {
FILE *logfile_fd; // log file
#endif
unsigned char *addr; // pointer to framebuffer memory
- unsigned ns[7]; // n-parameters
+ unsigned ns[9]; // n-parameters
const char *image_filename;
struct fb_var_screeninfo scr_var;
struct fb_fix_screeninfo scr_fix;
@@ -95,6 +95,8 @@ struct globals {
#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 img_posx ns[7] // image horizontal position
+#define img_posy ns[8] // image vertical position
#if DEBUG
#define DEBUG_MESSAGE(strMessage, args...) \
@@ -426,10 +428,10 @@ static void fb_drawimage(void)
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;
+ if ((width + G.img_posx) > G.scr_var.xres)
+ width = G.scr_var.xres - G.img_posx;
+ if ((height + G.img_posy) > G.scr_var.yres)
+ height = G.scr_var.yres - G.img_posy;
for (j = 0; j < height; j++) {
unsigned char *pixel;
unsigned char *src;
@@ -437,7 +439,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 + (G.img_posy + j) * G.scr_fix.line_length + G.img_posx * G.bytes_per_pixel;
for (i = 0; i < width; i++) {
unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]);
fb_write_pixel(src, thispix);
@@ -460,6 +462,7 @@ static void init(const char *cfg_filename)
"BAR_WIDTH\0" "BAR_HEIGHT\0"
"BAR_LEFT\0" "BAR_TOP\0"
"BAR_R\0" "BAR_G\0" "BAR_B\0"
+ "IMG_LEFT\0" "IMG_TOP\0"
#if DEBUG
"DEBUG\0"
#endif
@@ -472,10 +475,10 @@ static void init(const char *cfg_filename)
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 < 9)
G.ns[i] = val;
#if DEBUG
- if (i == 7) {
+ if (i == 9) {
G.bdebug_messages = val;
if (G.bdebug_messages)
G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log");