<?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>Ishan&#039;s way</title>
	<atom:link href="http://blog.ishans.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ishans.info</link>
	<description>The pathway of a potential geek</description>
	<lastBuildDate>Thu, 19 Jan 2012 05:51:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>A simple FAT32 bootloader written in assembly to boot from USB drives.</title>
		<link>http://blog.ishans.info/2012/01/19/a-simple-fat32-bootloader-written-in-assembly-to-boot-from-usb-drives/</link>
		<comments>http://blog.ishans.info/2012/01/19/a-simple-fat32-bootloader-written-in-assembly-to-boot-from-usb-drives/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 19:06:39 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[About]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[Bootloader]]></category>
		<category><![CDATA[Operating Systems development]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=199</guid>
		<description><![CDATA[This is an assignment done by me for a second year project &#160;in the university. The goal was to write a bootloader that can boot the given OS (&#160;JOSH&#160;) from a pen drive which is having FAT32 file system( We were supplied with a bootloader that could boot only from a FAT12 file system ).&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>This is an assignment done by me for a second year project &nbsp;in the university. The goal was to write a bootloader that can boot the given OS (&nbsp;<a href="http://www.mohanraj.info/josh.jsp">JOSH</a>&nbsp;) from a pen drive which is having FAT32 file system( We were supplied with a bootloader that could boot only from a FAT12 file system ).&nbsp;</p>
<p>&nbsp;</p>
<p><strong>What this bootloader can do:</strong></p>
<p>&nbsp;</p>
<p>It can load the first file( which should be a file less than 4096 bytes) which is located in a USB drive with a FAT32 file&nbsp;system to the memory and hand over the execution to that program.</p>
<p>&nbsp;</p>
<p><strong>Download location:</strong></p>
<p>&nbsp;</p>
<p><a href="https://github.com/ishanthilina/USB-FAT32-Bootloader">https://github.com/ishanthilina/USB-FAT32-Bootloader</a></p>
<p>&nbsp;</p>
<p><strong>Steps to use the Bootloader:</strong></p>
<p>&nbsp;</p>
<p>Included in the README file in gitHub.&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>More information can be found in the pdf in the <strong>doc</strong> folder.&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2012/01/19/a-simple-fat32-bootloader-written-in-assembly-to-boot-from-usb-drives/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>saveMyStatus &#8211; A script to manage the chat statuses in a better way in Empathy</title>
		<link>http://blog.ishans.info/2012/01/19/savemystatus-a-script-to-manage-the-chat-statuses-in-a-better-way-in-empathy/</link>
		<comments>http://blog.ishans.info/2012/01/19/savemystatus-a-script-to-manage-the-chat-statuses-in-a-better-way-in-empathy/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 18:33:55 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Empathy]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=192</guid>
		<description><![CDATA[This is a script I wrote long time ago.It will load the last used status when Empathy restarts or&#160;when one of the accounts of the user comes online. This functionality was not available in Empathy at the time I wrote this script. Every time I restart Empathy, its chat status was reset to &#8220;Available&#8221;. But [...]]]></description>
			<content:encoded><![CDATA[<p>This is a script I wrote long time ago.It will load the last used status when Empathy restarts or&nbsp;when one of the accounts of the user comes online. This functionality was not available in Empathy at the time I wrote this script. Every time I restart Empathy, its chat status was reset to &#8220;Available&#8221;. But now it seems that the new Empathy versions has the capability to remember the last used chat status (whether it was &#8220;Available&#8221;, &#8220;Busy&#8221;, &#8220;Away&#8221;, or &#8220;Invisible&#8221;). &nbsp;But still Empathy cannot remember the chat status message that was used in the last time. This script adds all this functionality to Empathy.</p>
<p><strong>How to use this:</strong></p>
<p><strong></strong><br />
(These guidelines are for Ubuntu 11.04 . But procedure will be lot common<br />
in other Linux flavours too)</p>
<p style="padding-left: 30px;">0) Get the code from&nbsp;<a href="https://github.com/ishanthilina/saveMyStatus">https://github.com/ishanthilina/saveMyStatus</a></p>
<p style="padding-left: 30px;">1).Create a folder named &#8220;.scripts&#8221; in the home directory. Copy this script to that folder.<br />
2).Go to Startup Application Preferences (search for &#8220;startup&#8221; in dashboard).<br />
3).Click Add.<br />
4).Give any Name you like.<br />
5).In Command, click on Browse and select your script from the file browser (which is in<br />
/home/<your user="" name="">/.scripts)<br />
6).Add a comment if you like.</your></p>
<p>Now the script will run from the next time you login to the computer. Have fun. And don&#8217;t forget to give me feedback <img src='http://blog.ishans.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2012/01/19/savemystatus-a-script-to-manage-the-chat-statuses-in-a-better-way-in-empathy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix the Folderview screenlet properties dialog exception throw</title>
		<link>http://blog.ishans.info/2012/01/15/how-to-fix-the-folderview-screenlet-properties-dialog-exception-throw/</link>
		<comments>http://blog.ishans.info/2012/01/15/how-to-fix-the-folderview-screenlet-properties-dialog-exception-throw/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 05:32:01 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Screenlets]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=176</guid>
		<description><![CDATA[Folderview screenlet is one of the screenlets that I have found very useful. But it doesn&#8217;t function correctly with the new python version (python 2.7). When the option is selected to view the properties dialog it gives the following exception. Traceback (most recent call last): &#160; File &#8220;/usr/lib/python2.7/site-packages/screenlets/__init__.py&#8221;, line 1913, in button_press &#160; &#160; self.menuitem_callback(widget,&#8217;info&#8217;) [...]]]></description>
			<content:encoded><![CDATA[<p>Folderview screenlet is one of the screenlets that I have found very useful. But it doesn&#8217;t function correctly with the new python version (python 2.7). When the option is selected to view the properties dialog it gives the following exception.</p>
<blockquote><p>Traceback (most recent call last):</p>
<p>&nbsp; File &#8220;/usr/lib/python2.7/site-packages/screenlets/__init__.py&#8221;, line 1913, in button_press</p>
<p>&nbsp; &nbsp; self.menuitem_callback(widget,&#8217;info&#8217;)</p>
<p>&nbsp; File &#8220;/usr/lib/python2.7/site-packages/screenlets/__init__.py&#8221;, line 2119, in menuitem_callback</p>
<p>&nbsp; &nbsp; self.show_settings_dialog()</p>
<p>&nbsp; File &#8220;/usr/lib/python2.7/site-packages/screenlets/__init__.py&#8221;, line 1570, in show_settings_dialog</p>
<p>&nbsp; &nbsp; se.set_info(self.__name__, glib.markup_escape_text(self.__desc__), &#8216;(c) &#8216; + glib.markup_escape_text(self.__author__),&nbsp;</p>
<p>TypeError: glib.markup_escape_text() argument 1 must be string or read-only buffer, not None</p>
<div>&nbsp;</div>
</blockquote>
<p>It seems that the variable <strong>__desc__</strong>&nbsp;is not set when calling the&nbsp;<strong>glib.markup_escape_text() </strong>method. So until some geek comes and fix this bug, we can use the following method to overcome this burden. (You&#8217;ll be able to follow the same procedure if you are getting this error for some other screenlet too <img src='http://blog.ishans.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />  )</p>
<ul>
<li>Open <strong>__init__.py</strong> &nbsp;in <strong>/usr/lib/python2.7/site-packages/screenlets</strong> with root&nbsp;privileges.&nbsp;</li>
<li>Find the line&nbsp;<strong>se.set_info(self.__name__, glib.markup_escape_text(self.__desc__), &#8216;(c) &#8216; + glib.markup_escape_text(self.__author__)</strong> . This should approximately be in the line 1570.</li>
<li>Add the following code segment before that line.</li>
</ul>
<p style="padding-left: 120px;"><strong>if not self.__desc__:</strong></p>
<p style="padding-left: 150px;"><strong>self.__desc__=&#8217;Description not set&#8217;</strong></p>
<p style="padding-left: 30px;">(keep in mind that python is sensitive to indentations).</p>
<ul>
<li>Save and restart the screenlet.</li>
</ul>
<div>&nbsp;</div>
<p>Congratulations&#8230;! You have fixed a bug in a very naive way&#8230;.! .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2012/01/15/how-to-fix-the-folderview-screenlet-properties-dialog-exception-throw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set brightness automatically at the startup in Linux</title>
		<link>http://blog.ishans.info/2011/09/25/set-brightness-automatically-at-the-startup-in-linux/</link>
		<comments>http://blog.ishans.info/2011/09/25/set-brightness-automatically-at-the-startup-in-linux/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 05:42:12 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=158</guid>
		<description><![CDATA[When ever I restart (or logout and login) my laptop the LCD display brightness is set to the maximum value. Even if I set the brightness settings in the power to the value I need, they won&#8217;t be in effect when I restart the machine. &#160; To solve this problem I wrote the following python [...]]]></description>
			<content:encoded><![CDATA[<p>When ever I restart (or logout and login) my laptop the LCD display brightness is set to the maximum value. Even if I set the brightness settings in the power to the value I need, they won&#8217;t be in effect when I restart the machine.</p>
<p>&nbsp;</p>
<p>To solve this problem I wrote the following python script. First you need to add it to the startup applications list. The command to be given in the startup applications is “<strong>python /&lt;path&gt;/&lt;to&gt;/&lt;script&gt;/setBrightness.py</strong>”.</p>
<p>&nbsp;</p>
<p>By default, the script will set the brightness to the minimum value. But if you want to change this, you can do that by editing the value 0 of the “<strong>value</strong>” variable to any value between 0 to 100.</p>
<p>Download::</p>
<p><a href="http://ishans.info/attachments/category/40/setBrightness.py">http://ishans.info/attachments/category/40/setBrightness.py</a></p>
<p>&nbsp;</p>
<p>PS:</p>
<p>&nbsp;</p>
<p>It seems that D-bus interfaces have been changed recently (From Gnome 3 onwards). So if you use Ubuntu 11.10 or any other gnome 3 compatible OS, please use the following script.</p>
<p>&nbsp;</p>
<p><a href="http://ishans.info/attachments/article/65/setBrightness.py" target="_blank">http://ishans.info/attachments/article/65/setBrightness.py</a></p>
<p>&nbsp;</p>
<p>All of the above code can now be conveniently accessed from Git-hub via <a href="https://github.com/ishanthilina/setBrightness">https://github.com/ishanthilina/setBrightness</a> . There are branches for every version of the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2011/09/25/set-brightness-automatically-at-the-startup-in-linux/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Start empathy automatically when network connection is available</title>
		<link>http://blog.ishans.info/2011/09/24/start-empathy-automatically-when-network-connection-is-available/</link>
		<comments>http://blog.ishans.info/2011/09/24/start-empathy-automatically-when-network-connection-is-available/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 15:42:02 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[D-bus]]></category>
		<category><![CDATA[Empathy]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=147</guid>
		<description><![CDATA[I have noticed that Empathy (the default multi-protocol chat client in Ubuntu 11.04) doesn&#8217;t re-login to the accounts after the network is dropped and re-connected. So I wrote the following python script to solve this problem. The script will be using D-bus signals to detect the network connection status.This will make empathy to, &#160; connect [...]]]></description>
			<content:encoded><![CDATA[<p>I have noticed that Empathy (the default multi-protocol chat client in Ubuntu 11.04) doesn&#8217;t re-login to the accounts after the network is dropped and re-connected. So I wrote the following python script to solve this problem. The script will be using D-bus signals to detect the network connection status.This will make empathy to,</p>
<p>&nbsp;</p>
<ul>
<li>connect automatically when network connection is established (even when empathy is not running).</li>
<li>re-login to accounts when the network gets dropped and reconnect again(very useful when using wireless connections).</li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>To use this script add it to the startup applications. Command to be given is “<strong>python /&lt;path&gt;/&lt;to&gt;/&lt;script&gt;/empathyConnect.py</strong>”</p>
<p>&nbsp;</p>
<p>Download::<a title="Download empathyConnect" href="http://ishans.info/attachments/article/64/empathyConnect.py"> http://ishans.info/attachments/article/64/empathyConnect.py</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2011/09/24/start-empathy-automatically-when-network-connection-is-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Slick sound problems in Linux</title>
		<link>http://blog.ishans.info/2011/07/30/java-slick-sound-problems-in-linux/</link>
		<comments>http://blog.ishans.info/2011/07/30/java-slick-sound-problems-in-linux/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 15:15:45 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Slick]]></category>
		<category><![CDATA[slick engine]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=140</guid>
		<description><![CDATA[My operating system is Ubuntu Linux 11.04 and I am using Java Slick library to build a game in these days. I faced the following error when I tried to load sounds using Music backMus=new Music(“path/to/file”); . &#160; &#160; INFO:Initialising sounds.. AL lib: oss.c:179: Could not open /dev/dsp: No such file or directory ERROR:Sound initialisation [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } -->My operating system is Ubuntu Linux 11.04 and I am using Java Slick library to build a game in these days. I faced the following error when I tried to load sounds using <strong>Music backMus=new Music(“path/to/file”);</strong> .</p>
<p>&nbsp;</p>
<p>&nbsp;<br />
<pre><strong>INFO:Initialising sounds..</strong></pre><br />
<pre><strong>AL lib: oss.c:179: Could not open /dev/dsp: No such file or directory</strong></pre><br />
<pre><strong>ERROR:Sound initialisation failure.</strong></pre><br />
<pre><strong>ERROR:Could not locate OpenAL library. org.lwjgl.LWJGLException: Could not locate OpenAL library.</strong></pre><br />
<!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } -->Searched everywhere for hours to find a solution for this and tried many guides which were written to solve this problem, but none of them were a success. Finally I got to know that this error is caused because Slick library uses a very old version of LWJGL (Light Weight Java Gaming Library). If you too are having this same problem use the following guidelines to rectify it.</p>
<p>&nbsp;</p>
<ul>
<li>Download the latest version of LWJGL from <a href="http://lwjgl.org/download.php">http://lwjgl.org/download.php</a>.(Download the file named lwjgl-x.x.x.zip).</li>
<li>Extract the downloaded file.</li>
<li>Copy the libraries that you are using from the jar folder in the extracted directory to your games Slick library folder. (Confirm file overwrites).</li>
<li>Copy the relevant native files from the native folder to your games Slick natives folder. (Confirm file overwrites).</li>
<li>Now reload the libraries in your IDE-if you are using any (For an example,in Net Beans remove all the slick libraries and add them again).</li>
</ul>
<p>&nbsp;</p>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } -->Now the game will play the sounds smoothly&#8230;!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2011/07/30/java-slick-sound-problems-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to put Conky under the windows?</title>
		<link>http://blog.ishans.info/2011/06/03/how-to-put-conky-under-the-windows/</link>
		<comments>http://blog.ishans.info/2011/06/03/how-to-put-conky-under-the-windows/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 10:33:03 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Conky]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[About]]></category>
		<category><![CDATA[Eye candy]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=134</guid>
		<description><![CDATA[Some of you may have experienced the problem of Conky being over the windows when the machine starts. So you have to manually restart Conky using killall conky; conky . But this can be easily avoided by editing the .conkyrc file. All you have to do is to set the &#8220;own_window_type&#8221; option to &#8220;normal&#8221;. Then [...]]]></description>
			<content:encoded><![CDATA[<p>Some of you may have experienced the problem of Conky being over the windows when the machine starts. So you have to manually restart Conky using <strong>killall conky; conky</strong> . But this can be easily avoided by editing the .conkyrc file. All you have to do is to set the <strong>&#8220;own_window_type&#8221;</strong> option to <strong>&#8220;normal&#8221;</strong>. Then Conky will appear under the windows when the OS restarts.</p>
<p>Happy Conkying&#8230;.!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2011/06/03/how-to-put-conky-under-the-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mod_rewrite problems in Apache2 + Ubuntu ?</title>
		<link>http://blog.ishans.info/2011/05/09/mod_rewrite-problems-in-apache2-ubuntu/</link>
		<comments>http://blog.ishans.info/2011/05/09/mod_rewrite-problems-in-apache2-ubuntu/#comments</comments>
		<pubDate>Mon, 09 May 2011 14:58:48 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Apache2]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=128</guid>
		<description><![CDATA[How to check whether mod_rewrite is installed? Create a text file named check.php in the www folder and insert the following code to it. &#60;?php phpinfo(); ?&#62; Then go to the web page in your browser using the url &#8220;localhost/check.php&#8221;. Then you&#8217;ll see information about the php version of the system. Under the &#8220;Configuration&#8221; title [...]]]></description>
			<content:encoded><![CDATA[<p><strong>How to check whether mod_rewrite is installed?</strong></p>
<p>Create a text file named check.php in the www folder and insert the following code to it.</p>
<p>&lt;?php phpinfo(); ?&gt;</p>
<p>Then go to the web page in your browser using the url &#8220;localhost/check.php&#8221;. Then you&#8217;ll see information about the php version of the system. Under the &#8220;Configuration&#8221; title there&#8217;s another title called &#8220;apache2handler&#8221;. In that table there&#8217;ll be a entry named &#8220;Loaded Modules&#8221;. Check to see if it contains the name &#8220;mod_rewrite &#8220;.If you can see that name then mod_rewrite is installed to apache.</p>
<p><strong>If mod_rewrite is not installed?</strong></p>
<p>mod_rewrite can be installed using the &#8220;sudo a2enmod rewrite&#8221; command in the terminal.</p>
<p><strong>How to check whether mod_rewrite is working properly?</strong></p>
<p>A good tutorial on this can be found in <a href="http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html" target="_blank">http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html</a>.</p>
<p><strong>mod_rewrite is not working even though it is installed?</strong></p>
<p>Navigate to /etc/apache2/sites-enabled as root and open the text file &#8220;000-default&#8221;. Then replace all the &#8220;AllowOverride None&#8221; with &#8220;AllowOverride All&#8221;( There&#8217;ll be 3 entries ). Then restart apache using sudo /etc/init.d/apache2 restart .</p>
<p>This should solve the problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2011/05/09/mod_rewrite-problems-in-apache2-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Can&#8217;t play songs in Amarok after installing it in ubuntu?</title>
		<link>http://blog.ishans.info/2011/02/10/cant-play-songs-in-amarok-after-installing-it-in-ubuntu/</link>
		<comments>http://blog.ishans.info/2011/02/10/cant-play-songs-in-amarok-after-installing-it-in-ubuntu/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 12:50:27 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Amarok]]></category>
		<category><![CDATA[KDE]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=121</guid>
		<description><![CDATA[I installed Amarok in Ubuntu Yesterday. But the problem was it couldn&#8217;t play mp3/mpg/mp4/m4a files. After a bit of searching I was able to figure out a solution. What you have to do is to install libxine1-ffmpeg package. It just a simple sudo apt-get install libxine1-ffmpeg Then everything worked fine for me. Hope this helps&#8230;!]]></description>
			<content:encoded><![CDATA[<p><!-- p { margin-bottom: 0.08in; } -->I installed Amarok in Ubuntu Yesterday. But the problem was it couldn&#8217;t play mp3/mpg/mp4/m4a files. After a bit of searching I was able to figure out a solution. What you have to do is to install <strong>libxine1-ffmpeg</strong> package. It just a simple<br />
<pre style="color: #d1d1d1; background: #000000;">sudo apt<span style="color: #d2cd86;">-</span>get install libxine1<span style="color: #d2cd86;">-</span>ffmpeg
</pre><br />
Then everything worked fine for me. Hope this helps&#8230;!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2011/02/10/cant-play-songs-in-amarok-after-installing-it-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Handling images in java using imageIO</title>
		<link>http://blog.ishans.info/2011/01/24/handling-images-in-java-using-imageio/</link>
		<comments>http://blog.ishans.info/2011/01/24/handling-images-in-java-using-imageio/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 15:16:51 +0000</pubDate>
		<dc:creator>Ishan Thilina Somasiri</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.ishans.info/?p=100</guid>
		<description><![CDATA[Have you ever faced the need of sending an image through a network using a Java program? If yes, you must have probably read the image to a byte array sent it through the network. The problem with this method is it is too long and you have to remake the image file ( using [...]]]></description>
			<content:encoded><![CDATA[<p><!-- p { margin-bottom: 0.08in; } -->Have you ever faced the need of sending an image through a network using a Java program? If yes, you must have probably read the image to a byte array sent it through the network. The problem with this method is it is too long and you have to remake the image file ( using the received byte array) at the destination to take any use of it.</p>
<p>But in this article I&#8217;m going to show how to read an image to a Java class called “Image” and use it appropriately. You can use this “Image” class directly in GUI&#8217;s, send it through networks, store it, etc. Sol let&#8217;s look at the code now. The code consists of two parts. Reading the image to an instance of the “Image” class and writing it back to the hard drive. I have put comments in almost every step. So understanding the code should be easy.<br />
<pre style="color: #d1d1d1; background: #4F5962;"><span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">awt</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">Graphics2D</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">awt</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">Image</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">awt</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">image</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">BufferedImage</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">io</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">File</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">io</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">IOException</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">util</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">Iterator</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">util</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">logging</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">Level</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> java</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">util</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">logging</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">Logger</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> javax</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">imageio</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">ImageIO</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> javax</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">imageio</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">ImageReadParam</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> javax</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">imageio</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">ImageReader</span><span style="color: #b060b0;">;</span>
<span style="color: #e66170; font-weight: bold;">import</span><span style="color: #008073;"> javax</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">imageio</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">stream</span><span style="color: #d2cd86;">.</span><span style="color: #008073;">ImageInputStream</span><span style="color: #b060b0;">;</span>

<span style="color: #e66170; font-weight: bold;">public</span> <span style="color: #e66170; font-weight: bold;">class</span> Main <span style="color: #b060b0;">{</span>

 <span style="color: #e66170; font-weight: bold;">public</span> <span style="color: #bb7977;">void</span> copyImage<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">{</span>

 <span style="color: #9999a9;">//path of the image to be read</span>
 <span style="color: #bb7977; font-weight: bold;">String</span> path<span style="color: #d2cd86;">=</span><span style="color: #00c4c4;">"picture.jpg"</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//create a file entry in java for that image</span>
 <span style="color: #bb7977; font-weight: bold;">File</span> imageSrc<span style="color: #d2cd86;">=</span><span style="color: #e66170; font-weight: bold;">new</span> <span style="color: #bb7977; font-weight: bold;">File</span><span style="color: #d2cd86;">(</span>path<span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #e66170; font-weight: bold;">if</span><span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">!</span>imageSrc<span style="color: #d2cd86;">.</span>exists<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">{</span>
 <span style="color: #bb7977; font-weight: bold;">System</span><span style="color: #d2cd86;">.</span>out<span style="color: #d2cd86;">.</span>println<span style="color: #d2cd86;">(</span><span style="color: #00c4c4;">"Input image does not exist."</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>
 <span style="color: #bb7977; font-weight: bold;">System</span><span style="color: #d2cd86;">.</span>exit<span style="color: #d2cd86;">(</span><span style="color: #008c00;">0</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>
 <span style="color: #b060b0;">}</span>

 <span style="color: #e66170; font-weight: bold;">try</span> <span style="color: #b060b0;">{</span>

 <span style="color: #9999a9;">/*</span>
<span style="color: #9999a9;"> * This part of the code is for reading the image in to</span>
<span style="color: #9999a9;"> * an instance of an Image class.</span>
<span style="color: #9999a9;"> */</span>

 <span style="color: #9999a9;">//Create a stream to read the image</span>
 ImageInputStream iis <span style="color: #d2cd86;">=</span> ImageIO<span style="color: #d2cd86;">.</span>createImageInputStream<span style="color: #d2cd86;">(</span>imageSrc<span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>
 <span style="color: #9999a9;">/*</span>
<span style="color: #9999a9;"> * ImageIO is a class containing static convenience methods for locating</span>
<span style="color: #9999a9;"> *ImageReaders and ImageWriters, and performing simple encoding and decoding.</span>
<span style="color: #9999a9;"> */</span>

 <span style="color: #9999a9;">//get a collection of Image readers which support jpg</span>
 Iterator<span style="color: #d2cd86;">&lt;</span><span style="color: #d2cd86;">?</span><span style="color: #d2cd86;">&gt;</span> imgReaders <span style="color: #d2cd86;">=</span> ImageIO<span style="color: #d2cd86;">.</span>getImageReadersByFormatName<span style="color: #d2cd86;">(</span><span style="color: #00c4c4;">"jpg"</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//get the first image reader from the collection</span>
 ImageReader reader <span style="color: #d2cd86;">=</span> <span style="color: #d2cd86;">(</span>ImageReader<span style="color: #d2cd86;">)</span> imgReaders<span style="color: #d2cd86;">.</span>next<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//set the input for the image reader</span>
 reader<span style="color: #d2cd86;">.</span>setInput<span style="color: #d2cd86;">(</span>iis<span style="color: #d2cd86;">,</span> <span style="color: #e66170; font-weight: bold;">true</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>
 <span style="color: #9999a9;">/*</span>
<span style="color: #9999a9;"> * Setting seekForwardOnly parameter ensures that the image file is</span>
<span style="color: #9999a9;"> * read in the ascending order.</span>
<span style="color: #9999a9;"> *</span>
<span style="color: #9999a9;"> */</span>

 <span style="color: #9999a9;">//to ensure that the default read parameters are used when</span>
 <span style="color: #9999a9;">//decoding data from the stream</span>
 ImageReadParam param <span style="color: #d2cd86;">=</span> reader<span style="color: #d2cd86;">.</span>getDefaultReadParam<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//read the image</span>
 <span style="color: #bb7977; font-weight: bold;">Image</span> image <span style="color: #d2cd86;">=</span> reader<span style="color: #d2cd86;">.</span>read<span style="color: #d2cd86;">(</span><span style="color: #008c00;">0</span><span style="color: #d2cd86;">,</span> param<span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">/*</span>
<span style="color: #9999a9;"> *</span>
<span style="color: #9999a9;"> * This part of the code is for writing the image object</span>
<span style="color: #9999a9;"> * back to the hard disk as an image file.</span>
<span style="color: #9999a9;"> */</span>

 <span style="color: #9999a9;">//To render the image</span>
 BufferedImage bufferedImage <span style="color: #d2cd86;">=</span> <span style="color: #e66170; font-weight: bold;">new</span> BufferedImage<span style="color: #d2cd86;">(</span>image<span style="color: #d2cd86;">.</span>getWidth<span style="color: #d2cd86;">(</span><span style="color: #e66170; font-weight: bold;">null</span><span style="color: #d2cd86;">)</span><span style="color: #d2cd86;">,</span>
image<span style="color: #d2cd86;">.</span>getHeight<span style="color: #d2cd86;">(</span><span style="color: #e66170; font-weight: bold;">null</span><span style="color: #d2cd86;">)</span><span style="color: #d2cd86;">,</span> BufferedImage<span style="color: #d2cd86;">.</span>TYPE_INT_RGB<span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//using "painter" we can draw in to "bufferedImage"</span>
 Graphics2D painter <span style="color: #d2cd86;">=</span> bufferedImage<span style="color: #d2cd86;">.</span>createGraphics<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//draw the "image" to the "bufferedImage"</span>
 painter<span style="color: #d2cd86;">.</span>drawImage<span style="color: #d2cd86;">(</span>image<span style="color: #d2cd86;">,</span> <span style="color: #e66170; font-weight: bold;">null</span><span style="color: #d2cd86;">,</span> <span style="color: #e66170; font-weight: bold;">null</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//the new image file</span>
 <span style="color: #bb7977; font-weight: bold;">File</span> outputImg<span style="color: #d2cd86;">=</span><span style="color: #e66170; font-weight: bold;">new</span> <span style="color: #bb7977; font-weight: bold;">File</span><span style="color: #d2cd86;">(</span><span style="color: #00c4c4;">"output.jpg"</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #9999a9;">//write the image to the file</span>
 ImageIO<span style="color: #d2cd86;">.</span>write<span style="color: #d2cd86;">(</span>bufferedImage<span style="color: #d2cd86;">,</span> <span style="color: #00c4c4;">"jpg"</span><span style="color: #d2cd86;">,</span> outputImg<span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #bb7977; font-weight: bold;">System</span><span style="color: #d2cd86;">.</span>out<span style="color: #d2cd86;">.</span>println<span style="color: #d2cd86;">(</span><span style="color: #00c4c4;">"Image transfer was successful...!"</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>

 <span style="color: #b060b0;">}</span> <span style="color: #e66170; font-weight: bold;">catch</span> <span style="color: #d2cd86;">(</span><span style="color: #bb7977; font-weight: bold;">IOException</span> ex<span style="color: #d2cd86;">)</span> <span style="color: #b060b0;">{</span>
 Logger<span style="color: #d2cd86;">.</span>getLogger<span style="color: #d2cd86;">(</span>Main<span style="color: #d2cd86;">.</span>class<span style="color: #d2cd86;">.</span>getName<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #d2cd86;">)</span><span style="color: #d2cd86;">.</span>log<span style="color: #d2cd86;">(</span>Level<span style="color: #d2cd86;">.</span>SEVERE<span style="color: #d2cd86;">,</span> <span style="color: #e66170; font-weight: bold;">null</span><span style="color: #d2cd86;">,</span> ex<span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>
 <span style="color: #b060b0;">}</span>
 <span style="color: #b060b0;">}</span>

 <span style="color: #e66170; font-weight: bold;">public</span> <span style="color: #e66170; font-weight: bold;">static</span> <span style="color: #bb7977;">void</span> main<span style="color: #d2cd86;">(</span><span style="color: #bb7977; font-weight: bold;">String</span><span style="color: #d2cd86;">[</span><span style="color: #d2cd86;">]</span> args<span style="color: #d2cd86;">)</span> <span style="color: #b060b0;">{</span>
 <span style="color: #9999a9;">// </span><span style="color: #ffffff; background: #3c215f;">TODO code application logic here</span>

 Main main<span style="color: #d2cd86;">=</span><span style="color: #e66170; font-weight: bold;">new</span> Main<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>
 main<span style="color: #d2cd86;">.</span>copyImage<span style="color: #d2cd86;">(</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span>
 <span style="color: #b060b0;">}</span>

<span style="color: #b060b0;">}</span></pre><br />
You can download the text file<a href="http://blog.ishans.info/attachments/2011-01-24/main%20code/Main.java" target="_self"> from here.</a></p>
<p>As you must have understood, I have written the code to read a JPEG image. I tested the same code for BMP,  PNG, and TIFF. All those formats worked just fine. The only draw back that I saw was there is a quality loss when using JPEG. To change the image format, change the following code segments (change xxx to the desired foramt).<br />
<pre style="color: #d1d1d1; background: #4F5962;"><span style="color: #9999a9;">//path of the image to be read</span>

String path="picture.xxx"<span style="color: #d2cd86;">;</span></pre><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<pre style="color: #d1d1d1; background: #4F5962;"><span style="color: #9999a9;">//get a collection of Image readers which support jpg</span>
 Iterator&lt;?&gt; imgReaders = ImageIO.getImageReadersByFormatName("xxx")<span style="color: #d2cd86;">;</span></pre><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<pre style="color: #d1d1d1; background: #4F5962;"><span style="color: #9999a9;">//the new image file</span>
File outputImg<span style="color: #d2cd86;">=</span><span style="color: #e66170; font-weight: bold;">new</span> File<span style="color: #d2cd86;">(</span><span style="color: #02d045;">"</span><span style="color: #00c4c4;">output.xxx</span><span style="color: #02d045;">"</span><span style="color: #d2cd86;">)</span><span style="color: #b060b0;">;</span></pre><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
<pre style="color: #d1d1d1; background: #4F5962;"><span style="color: #9999a9;">//write the image to the file</span>
ImageIO.write(bufferedImage, "bmp", outputImg)<span style="color: #d2cd86;">;</span></pre><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p><!-- p { margin-bottom: 0.08in; } -->If you used a byte array to read the image file, you have to make an image file( on the hard drive) before you use that image again. But using the above method you can directly use it in the Java program.<a href="http://blog.ishans.info/attachments/2011-01-24/demo/Main.java" target="_self"> Click here </a>to see an example on that.</p>
<p>As you can see, the possibilities are endless. So experiment and enjoy&#8230;..!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ishans.info/2011/01/24/handling-images-in-java-using-imageio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

