summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/fbsplash.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 5b2e5ac..bc3c610 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");