Archive for January, 2009

 

Reverse a linked list, recursive method

Jan 29, 2009 in Algorithms

from
http://javadecodedquestions.blogspot.com/2013/01/java-interviews-frequently-asked-puzzles.html

[java]

public static ListNode reverse (ListNode list) {
if (list == null)
return null;
if (list.next == null)
return list;
ListNode secondElem = list.next;
list.next = null;
ListNode reverseRest = reverse(secondElem);
secondElem.next = list;
return reverseRest;
}

[/java]

Converting jpg to png in C# (CSharp) ..

Jan 12, 2009 in .Net, Uncategorized

using System.Drawing;
using System.Drawing.Imaging;

// apt-get install libgdiplus

class CGTest1 {

    public static void Main() {

        /* Image bmpImageToConvert =
           System.Drawing.Image.FromFile(
           Server.MapPath(strUploadImagePath));
         */

        Image bmpImageToConvert = Image.FromFile("images/sample3.jpg");
        Image bmpNewImage = new Bitmap(bmpImageToConvert.Width,
                                       bmpImageToConvert.Height);
        Graphics gfxNewImage = Graphics.FromImage(bmpNewImage);
        gfxNewImage.DrawImage(bmpImageToConvert,
                              new Rectangle(0, 0, bmpNewImage.Width,
                                            bmpNewImage.Height),
                              0, 0,
                              bmpImageToConvert.
                              Width,bmpImageToConvert.Height,
                              GraphicsUnit.Pixel);
        gfxNewImage.Dispose();
        bmpImageToConvert.Dispose();

        /*bmpNewImage.Save(Server.MapPath("userData/" &
          Request.QueryString("ID") & "/" & e.Item.Cells(2).Text &
          ".jpg"),ImageFormat.Jpeg)
         */

        bmpNewImage.Save("images/sample3t.png", ImageFormat.Png);
    }
}

Thanks to :

http://www.codeverge.net/ng.asp-net-forum.getting_started/converting-a-png-or-gif-to-a-jpeg

Searching for files in Debian distribution packages..

Jan 06, 2009 in Linux, Ubuntu

# apt-get install apt-file
# apt-file update
# apt-file search gtk+-2
libgtk-directfb-2.0-dev: /usr/lib/pkgconfig/libgtk-directfb-2.0-0/gtk+-2.0.pc
libgtk2.0-dev: /usr/lib/pkgconfig/gtk+-2.0.pc
lsb-build-desktop3: /usr/lib/lsb3/pkgconfig/gtk+-2.0.pc
valac: /usr/share/vala/vapi/gtk+-2.0.deps
valac: /usr/share/vala/vapi/gtk+-2.0.vapi