diff options
| author | Peter Korsgaard <peter@korsgaard.com> | 2018-03-29 13:35:01 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-29 18:42:11 +0200 |
| commit | a82fe671f5c7ff96ca4d4d813210d18e0b02c193 (patch) | |
| tree | 1a3575edf3de626a9271fa7c10d1fcdf800cb7a3 /miscutils | |
| parent | 03fd7e06f854d385070a6fc9714f445727c359cd (diff) | |
| download | busybox-w32-a82fe671f5c7ff96ca4d4d813210d18e0b02c193.tar.gz busybox-w32-a82fe671f5c7ff96ca4d4d813210d18e0b02c193.tar.bz2 busybox-w32-a82fe671f5c7ff96ca4d4d813210d18e0b02c193.zip | |
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.c | 21 |
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 @@ | |||
| 54 | //usage: "\n -d Framebuffer device (default /dev/fb0)" | 54 | //usage: "\n -d Framebuffer device (default /dev/fb0)" |
| 55 | //usage: "\n -i Config file (var=value):" | 55 | //usage: "\n -i Config file (var=value):" |
| 56 | //usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" | 56 | //usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" |
| 57 | //usage: "\n BAR_R,BAR_G,BAR_B" | 57 | //usage: "\n BAR_R,BAR_G,BAR_B,IMG_LEFT,IMG_TOP" |
| 58 | //usage: "\n -f Control pipe (else exit after drawing image)" | 58 | //usage: "\n -f Control pipe (else exit after drawing image)" |
| 59 | //usage: "\n commands: 'NN' (% for progress bar) or 'exit'" | 59 | //usage: "\n commands: 'NN' (% for progress bar) or 'exit'" |
| 60 | 60 | ||
| @@ -73,7 +73,7 @@ struct globals { | |||
| 73 | FILE *logfile_fd; // log file | 73 | FILE *logfile_fd; // log file |
| 74 | #endif | 74 | #endif |
| 75 | unsigned char *addr; // pointer to framebuffer memory | 75 | unsigned char *addr; // pointer to framebuffer memory |
| 76 | unsigned ns[7]; // n-parameters | 76 | unsigned ns[9]; // n-parameters |
| 77 | const char *image_filename; | 77 | const char *image_filename; |
| 78 | struct fb_var_screeninfo scr_var; | 78 | struct fb_var_screeninfo scr_var; |
| 79 | struct fb_fix_screeninfo scr_fix; | 79 | struct fb_fix_screeninfo scr_fix; |
| @@ -95,6 +95,8 @@ struct globals { | |||
| 95 | #define nbar_colr ns[4] // progress bar color red component | 95 | #define nbar_colr ns[4] // progress bar color red component |
| 96 | #define nbar_colg ns[5] // progress bar color green component | 96 | #define nbar_colg ns[5] // progress bar color green component |
| 97 | #define nbar_colb ns[6] // progress bar color blue component | 97 | #define nbar_colb ns[6] // progress bar color blue component |
| 98 | #define img_posx ns[7] // image horizontal position | ||
| 99 | #define img_posy ns[8] // image vertical position | ||
| 98 | 100 | ||
| 99 | #if DEBUG | 101 | #if DEBUG |
| 100 | #define DEBUG_MESSAGE(strMessage, args...) \ | 102 | #define DEBUG_MESSAGE(strMessage, args...) \ |
| @@ -426,10 +428,10 @@ static void fb_drawimage(void) | |||
| 426 | line_size = width*3; | 428 | line_size = width*3; |
| 427 | pixline = xmalloc(line_size); | 429 | pixline = xmalloc(line_size); |
| 428 | 430 | ||
| 429 | if (width > G.scr_var.xres) | 431 | if ((width + G.img_posx) > G.scr_var.xres) |
| 430 | width = G.scr_var.xres; | 432 | width = G.scr_var.xres - G.img_posx; |
| 431 | if (height > G.scr_var.yres) | 433 | if ((height + G.img_posy) > G.scr_var.yres) |
| 432 | height = G.scr_var.yres; | 434 | height = G.scr_var.yres - G.img_posy; |
| 433 | for (j = 0; j < height; j++) { | 435 | for (j = 0; j < height; j++) { |
| 434 | unsigned char *pixel; | 436 | unsigned char *pixel; |
| 435 | unsigned char *src; | 437 | unsigned char *src; |
| @@ -437,7 +439,7 @@ static void fb_drawimage(void) | |||
| 437 | if (fread(pixline, 1, line_size, theme_file) != line_size) | 439 | if (fread(pixline, 1, line_size, theme_file) != line_size) |
| 438 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); | 440 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); |
| 439 | pixel = pixline; | 441 | pixel = pixline; |
| 440 | src = G.addr + j * G.scr_fix.line_length; | 442 | src = G.addr + (G.img_posy + j) * G.scr_fix.line_length + G.img_posx * G.bytes_per_pixel; |
| 441 | for (i = 0; i < width; i++) { | 443 | for (i = 0; i < width; i++) { |
| 442 | unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]); | 444 | unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]); |
| 443 | fb_write_pixel(src, thispix); | 445 | fb_write_pixel(src, thispix); |
| @@ -460,6 +462,7 @@ static void init(const char *cfg_filename) | |||
| 460 | "BAR_WIDTH\0" "BAR_HEIGHT\0" | 462 | "BAR_WIDTH\0" "BAR_HEIGHT\0" |
| 461 | "BAR_LEFT\0" "BAR_TOP\0" | 463 | "BAR_LEFT\0" "BAR_TOP\0" |
| 462 | "BAR_R\0" "BAR_G\0" "BAR_B\0" | 464 | "BAR_R\0" "BAR_G\0" "BAR_B\0" |
| 465 | "IMG_LEFT\0" "IMG_TOP\0" | ||
| 463 | #if DEBUG | 466 | #if DEBUG |
| 464 | "DEBUG\0" | 467 | "DEBUG\0" |
| 465 | #endif | 468 | #endif |
| @@ -472,10 +475,10 @@ static void init(const char *cfg_filename) | |||
| 472 | int i = index_in_strings(param_names, token[0]); | 475 | int i = index_in_strings(param_names, token[0]); |
| 473 | if (i < 0) | 476 | if (i < 0) |
| 474 | bb_error_msg_and_die("syntax error: %s", token[0]); | 477 | bb_error_msg_and_die("syntax error: %s", token[0]); |
| 475 | if (i >= 0 && i < 7) | 478 | if (i >= 0 && i < 9) |
| 476 | G.ns[i] = val; | 479 | G.ns[i] = val; |
| 477 | #if DEBUG | 480 | #if DEBUG |
| 478 | if (i == 7) { | 481 | if (i == 9) { |
| 479 | G.bdebug_messages = val; | 482 | G.bdebug_messages = val; |
| 480 | if (G.bdebug_messages) | 483 | if (G.bdebug_messages) |
| 481 | G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log"); | 484 | G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log"); |
