{"id":42,"date":"2009-01-25T10:29:07","date_gmt":"2009-01-25T10:29:07","guid":{"rendered":"http:\/\/130.61.186.249\/index.php\/2009\/01\/25\/usplash-screen-for-ubuntu-with-animated-gif-2\/"},"modified":"2009-01-25T10:29:07","modified_gmt":"2009-01-25T10:29:07","slug":"usplash-screen-for-ubuntu-with-animated-gif-2","status":"publish","type":"post","link":"http:\/\/130.61.186.249\/index.php\/2009\/01\/25\/usplash-screen-for-ubuntu-with-animated-gif-2\/","title":{"rendered":"USplash screen for ubuntu with &#8220;animated gif&#8221;"},"content":{"rendered":"<p>Today I needed to change the boot screen of my ubuntu machine. It&#8217;s a computer (actually a mac mini) that I&#8217;m setting up to be used as a info screen in stores and on a 9m^2 led screen. We want the logo of the company to be the main focus when booting, so I set to create a theme for usplash in ubuntu, since I had already finished customizing rEfid.<br \/>\nI started reading this: <a href=\"https:\/\/help.ubuntu.com\/community\/USplashCustomizationHowto,\" target=\"_blank\" rel=\"noopener\">https:\/\/help.ubuntu.com\/community\/USplashCustomizationHowto,<\/a> which helped me to understand the basics, and find the source code example.<br \/>\nThe fact that the boot theme is coded in C, and that the functions is called 25 times a second, gave me an idea: I wanted a mac\/flash like loader like the ones you see at <a href=\"http:\/\/ajaxload.info\/.\" target=\"_blank\" rel=\"noopener\">http:\/\/ajaxload.info\/.<\/a> So I generated an animated gif from that page, with the colors that matched my theme.<br \/>\n<span class=\"imgcenter\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2015\/03\/ajax-loader.gif\" alt=\"\" \/><\/span><br \/>\nNext I had to split the animated gif into a bunch of png images, and generate a palette for my main theme image, and then reuse the palette on all the image files.<br \/>\nSplitting the gif is easy with ImageMagick:<\/p>\n<pre escaped=\"true\" lang=\"bash\" line=\"0\">convert loading.gif loading.png<\/pre>\n<p><span class=\"imgleft\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2015\/03\/loader_0.png\" alt=\"\" \/><\/span><span class=\"imgleft\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2015\/03\/loader_1.png\" alt=\"\" \/><\/span><span class=\"imgleft\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2015\/03\/loader_2.png\" alt=\"\" \/><\/span><span class=\"imgleft\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2015\/03\/loader_3.png\" alt=\"\" \/><\/span><br \/>\nThis makes loading-0.png through loading-11.png. In Photoshop it was easy to make a predefined &#8220;Action&#8221; that adds the palette, saves the file, closes it, and does the same to all the other pictures. (Also easy in Gimp of course)<br \/>\nThis is important because we are restricted to use 1 palette, so all the images need to have the same one. A tip is to add all the objects you need into the background image, then convert the image to indexed(256color) and extract the palette. Now you remove the objects again, and use this palette for all the images.<br \/>\nNow, the only thing left was the code.<br \/>\nIn the Makefile, I added loading_0.png.c.o through loading_12.png.c.o, so that make generates object files for the images. Next I went into the theme source file, and added an &#8220;extern struct usplash_pixmap&#8221; definition for all the images I needed.<br \/>\nFirst I needed to define the images in the code, so I could use the linked objects:<\/p>\n<pre escaped=\"true\" lang=\"c\" line=\"1\">struct usplash_pixmap *pixmap_loader[12];\nextern struct usplash_pixmap pixmap_loader_bg;\nextern struct usplash_pixmap pixmap_loader_0;\nextern struct usplash_pixmap pixmap_loader_1;\nextern struct usplash_pixmap pixmap_loader_2;\nextern struct usplash_pixmap pixmap_loader_3;\nextern struct usplash_pixmap pixmap_loader_4;\nextern struct usplash_pixmap pixmap_loader_5;\nextern struct usplash_pixmap pixmap_loader_6;\nextern struct usplash_pixmap pixmap_loader_7;\nextern struct usplash_pixmap pixmap_loader_8;\nextern struct usplash_pixmap pixmap_loader_9;\nextern struct usplash_pixmap pixmap_loader_10;\nextern struct usplash_pixmap pixmap_loader_11;<\/pre>\n<p>And added this code to the init section, to be able to reach the loading image from an array:<\/p>\n<pre escaped=\"true\" lang=\"c\" line=\"1\">void t_init(struct usplash_theme *theme) {\n    int x, y;\n    usplash_getdimensions(&amp;x, &amp;y);\n    theme-&gt;progressbar_x = (x - theme-&gt;pixmap-&gt;width)\/2 + theme-&gt;progressbar_x;\n    theme-&gt;progressbar_y = (y - theme-&gt;pixmap-&gt;height)\/2 + theme-&gt;progressbar_y;\n    pixmap_loader[0] = &amp;pixmap_loader_0;\n    pixmap_loader[1] = &amp;pixmap_loader_1;\n    pixmap_loader[2] = &amp;pixmap_loader_2;\n    pixmap_loader[3] = &amp;pixmap_loader_3;\n    pixmap_loader[4] = &amp;pixmap_loader_4;\n    pixmap_loader[5] = &amp;pixmap_loader_5;\n    pixmap_loader[6] = &amp;pixmap_loader_6;\n    pixmap_loader[7] = &amp;pixmap_loader_7;\n    pixmap_loader[8] = &amp;pixmap_loader_8;\n    pixmap_loader[9] = &amp;pixmap_loader_9;\n    pixmap_loader[10] = &amp;pixmap_loader_10;\n    pixmap_loader[11] = &amp;pixmap_loader_11;\n}<\/pre>\n<p>I now replaced the example t_animate_step function with the following:<\/p>\n<pre escaped=\"true\" lang=\"c\" line=\"1\">void t_animate_step(struct usplash_theme* theme, int pulsating) {\n    static int pulsate_step = 0;\n    unsigned char step_num = 0;\n    unsigned int position_x = theme-&gt;progressbar_x + (pixmap_throbber_back.width - pixmap_loader_bg.width) \/ 2;\n    if (pulsating) {\n        pulsate_step ++;\n        step_num = (unsigned char)(pulsate_step\/2) % 12;\n        usplash_put(position_x, theme-&gt;progressbar_y, &amp;pixmap_loader_bg);\n        usplash_put_part(position_x, theme-&gt;progressbar_y, 32, 32, pixmap_loader[step_num], 0, 0);\n    }\n}<\/pre>\n<p>Whats happening here is that when the &#8220;pulsating&#8221; flag is active, it increases the pulsate_step counter, and for each 2nd step\/frame, &#8220;step_num&#8221; increases, running from 0-11 and around again(using modulus). Then I draw first the background, and then the actual image.<br \/>\nI also had to add the following function t_draw_progressbar, so the &#8220;pulsating&#8221; loader, which is larger than the progressbar, doesn&#8217;t destroy the theme with remains of the &#8220;gif&#8221;.<\/p>\n<pre escaped=\"true\" lang=\"c\" line=\"1\">   unsigned int position_x = theme-&gt;progressbar_x + (pixmap_throbber_back.width - pixmap_loader_bg.width) \/ 2;\n   usplash_put(position_x, theme-&gt;progressbar_y, &amp;pixmap_loader_bg);<\/pre>\n<p>Result:<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2015\/03\/screenshot.jpg\" alt=\"\" \/><br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2015\/03\/screenshot2.jpg\" alt=\"\" \/><br \/>\nFull source code with images and binary:<br \/>\n<a class=\"attach\" href=\"http:\/\/files.myopera.com\/lunatic\/blog\/trippelm-usplash.tar.gz\" target=\"_blank\" rel=\"noopener\">trippelm-usplash.tar.gz<\/a><br \/>\nTip:<br \/>\nTo add a usplash theme to your ubuntu, you could install the nifty startup configurator:<\/p>\n<pre escaped=\"true\" lang=\"bash\" line=\"0\">apt-get install startupmanager<\/pre>\n<p>This will make it easy to add\/change the boot splash without using the console. Just add the .so file from your theme, and select it as the current boot splash.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I needed to change the boot screen of my ubuntu machine. It&#8217;s a computer (actually a mac mini) that I&#8217;m setting up to be used as a info screen in stores and on a 9m^2 led screen. We want the logo of the company to be the main focus when booting, so I set [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,9,10,31,32],"tags":[],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-boot-loader","category-boot-splash","category-bootsplash","category-ubuntu","category-usplash"],"_links":{"self":[{"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":0,"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/130.61.186.249\/index.php\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}