]> git.ozlabs.org Git - petitboot/commitdiff
jpeg background support and scaling
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 3 Apr 2007 05:41:07 +0000 (15:41 +1000)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 3 Apr 2007 05:41:07 +0000 (15:41 +1000)
Turn the background image into a jpeg and scale it to screen dimensions

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Makefile
artwork/background.jpg [new file with mode: 0644]
artwork/background.png [deleted file]
petitboot.c

index e3bba3e0e7ab2cf0164bbd80e2f7ce1a19af5811..e192b201692dd90b16e3a6addaeb2e897c17d072 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@ LDFLAGS =
 CFLAGS = -O0 -ggdb -Wall '-DPREFIX="$(PREFIX)"'
 
 PARSERS = native yaboot
 CFLAGS = -O0 -ggdb -Wall '-DPREFIX="$(PREFIX)"'
 
 PARSERS = native yaboot
-ARTWORK = background.png cdrom.png hdd.png usbpen.png cursor
+ARTWORK = background.jpg cdrom.png hdd.png usbpen.png cursor
 
 all: petitboot udev-helper
 
 
 all: petitboot udev-helper
 
diff --git a/artwork/background.jpg b/artwork/background.jpg
new file mode 100644 (file)
index 0000000..9d54d31
Binary files /dev/null and b/artwork/background.jpg differ
diff --git a/artwork/background.png b/artwork/background.png
deleted file mode 100644 (file)
index f6ea9da..0000000
Binary files a/artwork/background.png and /dev/null differ
index dfb293cbcd1bbf5f3bfd14f34db30450dc82a792..84a76f62fc092903a35308ba899c12c24ed5ddae 100644 (file)
@@ -13,6 +13,7 @@
 #include <libtwin/twin.h>
 #include <libtwin/twin_linux_mouse.h>
 #include <libtwin/twin_png.h>
 #include <libtwin/twin.h>
 #include <libtwin/twin_linux_mouse.h>
 #include <libtwin/twin_png.h>
+#include <libtwin/twin_jpeg.h>
 
 #include "petitboot.h"
 #include "petitboot-paths.h"
 
 #include "petitboot.h"
 #include "petitboot-paths.h"
@@ -853,6 +854,51 @@ int pboot_remove_device(const char *dev_id)
        return TWIN_TRUE;
 }
 
        return TWIN_TRUE;
 }
 
+static void pboot_make_background(void)
+{
+       twin_pixmap_t   *filepic, *scaledpic;
+       const char      *background_path;
+
+       /* Set background pixmap */
+       LOG("loading background...");
+       background_path = artwork_pathname("background.jpg");
+       filepic = twin_jpeg_to_pixmap(background_path, TWIN_ARGB32);
+       LOG("%s\n", filepic ? "ok" : "failed");
+
+       if (filepic == NULL)
+               return;
+
+       if (pboot_screen->height == filepic->height &&
+           pboot_screen->width == filepic->width)
+               scaledpic = filepic;
+       else {
+               twin_fixed_t    sx, sy;
+               twin_operand_t  srcop;
+
+               scaledpic = twin_pixmap_create(TWIN_ARGB32,
+                                              pboot_screen->width,
+                                              pboot_screen->height);
+               if (scaledpic == NULL) {
+                       twin_pixmap_destroy(filepic);
+                       return;
+               }
+               sx = twin_fixed_div(twin_int_to_fixed(filepic->width),
+                                   twin_int_to_fixed(pboot_screen->width));
+               sy = twin_fixed_div(twin_int_to_fixed(filepic->height),
+                                   twin_int_to_fixed(pboot_screen->height));
+               
+               twin_matrix_scale(&filepic->transform, sx, sy);
+               srcop.source_kind = TWIN_PIXMAP;
+               srcop.u.pixmap = filepic;
+               twin_composite(scaledpic, 0, 0, &srcop, 0, 0,
+                              NULL, 0, 0, TWIN_SOURCE,
+                              pboot_screen->width, pboot_screen->height);
+               twin_pixmap_destroy(filepic);
+                              
+       }
+       twin_screen_set_background(pboot_screen, scaledpic);
+}
+
 static void exitfunc(void)
 {
 #ifndef _USE_X11
 static void exitfunc(void)
 {
 #ifndef _USE_X11
@@ -870,9 +916,6 @@ static void sigint(int sig)
 
 int main(int argc, char **argv)
 {
 
 int main(int argc, char **argv)
 {
-       twin_pixmap_t *pic;
-       const char *background_path;
-
        atexit(exitfunc);
        signal(SIGINT, sigint);
 
        atexit(exitfunc);
        signal(SIGINT, sigint);
 
@@ -906,12 +949,7 @@ int main(int argc, char **argv)
 #endif
 
        /* Set background pixmap */
 #endif
 
        /* Set background pixmap */
-       background_path = artwork_pathname("background.png");
-       LOG("loading background: %s...", background_path);
-       pic = twin_png_to_pixmap(background_path, TWIN_ARGB32);
-       LOG("%s\n", pic ? "ok" : "failed");
-       if (pic)
-               twin_screen_set_background(pboot_screen, pic);
+       pboot_make_background();
 
        /* Init more stuffs */
        pboot_create_panels();
 
        /* Init more stuffs */
        pboot_create_panels();