<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Håkon Nessjøen &#187; bootsplash</title>
	<atom:link href="http://lunatic.no/category/bootsplash/feed/" rel="self" type="application/rss+xml" />
	<link>http://lunatic.no</link>
	<description>Just another life hacker</description>
	<lastBuildDate>Tue, 06 Dec 2011 22:39:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>USplash screen for ubuntu with &#8220;animated gif&#8221;</title>
		<link>http://lunatic.no/2009/01/usplash-screen-for-ubuntu-with-animated-gif-2/</link>
		<comments>http://lunatic.no/2009/01/usplash-screen-for-ubuntu-with-animated-gif-2/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 10:29:07 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[boot loader]]></category>
		<category><![CDATA[boot splash]]></category>
		<category><![CDATA[bootsplash]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[usplash]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[<div style="display:inline;float:right;margin-left:1em"><g:plusone href="http://lunatic.no/2009/01/usplash-screen-for-ubuntu-with-animated-gif-2/"></g:plusone></div>
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 [...]]]></description>
			<content:encoded><![CDATA[<div style="display:inline;float:right;margin-left:1em"><g:plusone href="http://lunatic.no/2009/01/usplash-screen-for-ubuntu-with-animated-gif-2/"></g:plusone></div>
<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.</p>
<p>I started reading this: <a href="https://help.ubuntu.com/community/USplashCustomizationHowto," target="_blank">https://help.ubuntu.com/community/USplashCustomizationHowto,</a> which helped me to understand the basics, and find the source code example.</p>
<p>The 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">http://ajaxload.info/.</a> So I generated an animated gif from that page, with the colors that matched my theme.<br />
<span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/ajax-loader.gif" alt="" /></span><br />
Next 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.</p>
<p>Splitting the gif is easy with ImageMagick:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">convert loading.gif loading.png</pre></div></div>

<p><span class="imgleft"><img src="http://files.myopera.com/lunatic/blog/loader_0.png" alt="" /></span><span class="imgleft"><img src="http://files.myopera.com/lunatic/blog/loader_1.png" alt="" /></span><span class="imgleft"><img src="http://files.myopera.com/lunatic/blog/loader_2.png" alt="" /></span><span class="imgleft"><img src="http://files.myopera.com/lunatic/blog/loader_3.png" alt="" /></span><br />
This 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)</p>
<p>This 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.</p>
<p>Now, the only thing left was the code.</p>
<p>In 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.</p>
<p>First I needed to define the images in the code, so I could use the linked objects:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> usplash_pixmap <span style="color: #339933;">*</span>pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">12</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_bg<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_0<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_1<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_2<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_3<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_4<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_5<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_6<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_7<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_8<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_9<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_10<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">extern</span> <span style="color: #993333;">struct</span> usplash_pixmap pixmap_loader_11<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And added this code to the init section, to be able to reach the loading image from an array:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> t_init<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> usplash_theme <span style="color: #339933;">*</span>theme<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> x<span style="color: #339933;">,</span> y<span style="color: #339933;">;</span>
    usplash_getdimensions<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>x<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    theme<span style="color: #339933;">-&gt;</span>progressbar_x <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">-</span> theme<span style="color: #339933;">-&gt;</span>pixmap<span style="color: #339933;">-&gt;</span>width<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #0000dd;">2</span> <span style="color: #339933;">+</span> theme<span style="color: #339933;">-&gt;</span>progressbar_x<span style="color: #339933;">;</span>
    theme<span style="color: #339933;">-&gt;</span>progressbar_y <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>y <span style="color: #339933;">-</span> theme<span style="color: #339933;">-&gt;</span>pixmap<span style="color: #339933;">-&gt;</span>height<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #0000dd;">2</span> <span style="color: #339933;">+</span> theme<span style="color: #339933;">-&gt;</span>progressbar_y<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_0<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_1<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_2<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_3<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_4<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_5<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_6<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_7<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_8<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_9<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_10<span style="color: #339933;">;</span>
    pixmap_loader<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">11</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>pixmap_loader_11<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I now replaced the example t_animate_step function with the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> t_animate_step<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> usplash_theme<span style="color: #339933;">*</span> theme<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> pulsating<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #993333;">static</span> <span style="color: #993333;">int</span> pulsate_step <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> step_num <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> position_x <span style="color: #339933;">=</span> theme<span style="color: #339933;">-&gt;</span>progressbar_x <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>pixmap_throbber_back.<span style="color: #202020;">width</span> <span style="color: #339933;">-</span> pixmap_loader_bg.<span style="color: #202020;">width</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>pulsating<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        pulsate_step <span style="color: #339933;">++;</span>
        step_num <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>pulsate_step<span style="color: #339933;">/</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #0000dd;">12</span><span style="color: #339933;">;</span>
        usplash_put<span style="color: #009900;">&#40;</span>position_x<span style="color: #339933;">,</span> theme<span style="color: #339933;">-&gt;</span>progressbar_y<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>pixmap_loader_bg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        usplash_put_part<span style="color: #009900;">&#40;</span>position_x<span style="color: #339933;">,</span> theme<span style="color: #339933;">-&gt;</span>progressbar_y<span style="color: #339933;">,</span> <span style="color: #0000dd;">32</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">32</span><span style="color: #339933;">,</span> pixmap_loader<span style="color: #009900;">&#91;</span>step_num<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<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.</p>
<p>I 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>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">   <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> position_x <span style="color: #339933;">=</span> theme<span style="color: #339933;">-&gt;</span>progressbar_x <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>pixmap_throbber_back.<span style="color: #202020;">width</span> <span style="color: #339933;">-</span> pixmap_loader_bg.<span style="color: #202020;">width</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
   usplash_put<span style="color: #009900;">&#40;</span>position_x<span style="color: #339933;">,</span> theme<span style="color: #339933;">-&gt;</span>progressbar_y<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>pixmap_loader_bg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Result:<br />
<img src="http://files.myopera.com/lunatic/blog/screenshot.png" alt="" /></p>
<p><img src="http://files.myopera.com/lunatic/blog/screenshot2.png" alt="" /></p>
<p>Full source code with images and binary:<br />
<a class="attach" href="http://files.myopera.com/lunatic/blog/trippelm-usplash.tar.gz" target="_blank">trippelm-usplash.tar.gz</a></p>
<p>Tip:<br />
To add a usplash theme to your ubuntu, you could install the nifty startup configurator:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> startupmanager</pre></div></div>

<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>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2009/01/usplash-screen-for-ubuntu-with-animated-gif-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

