Using libGD to manipulate jpeg images in C

Yesterday, for a small project of mine, I needed to implement a small utility to deform jpeg images from command line. The idea was to use texture mapping for deformations, so I needed a way to manipulate the jpeg images at the pixel level.

The first thing I tried was the imagemagik utility. I’ve browsed their documentation but I couldn’t find anything close to what I needed. I wanted to be able to draw textured mapped triangles into a picture. I knew that the Allegro library that I’ve used back in the old DOS programming days could do the texturing part. The bad thing that I found out is that it does not know how to handle jpeg files 🙁

Then I googled the Internet for a free and easy to use graphic library and I found libGD. The good thing is that it can handle jpeg files. The bad thing is that it cannot do the texturing part. The next thing I had in mind was to use both libraries but this would mean to add lots of dependencies to my small application for a simple texture mapping function. So I decided to write my own texture mapping function to remember the good old days. I will not describe how texture mapping works as there are plenty of tutorials on the internet for this.
Continue reading

Running X applications under chroot jail

Having a Gentoo32 chroot as a fallback on a Gentoo64 system is not unusual. Some things simply do not work on Gentoo 64 (as FlashPlayer 9) or you need a distcc server for the other (32 bit) systems.

I wrote a simple bash script that allows the X applications under chroot jail to connect to the XOrg server runing outside the jail.
You can find it here.


linux32 xchroot /mnt/gentoo32


I only tested it on Gentoo.

Sharp Zaurus Out of Production

It seems that Sharp will no longer produce the Zaurus line.

Hi all,

yes, we have to confirm that Sharp pulled the plug out
of the Zaurus line.
No successor model is planned, and the end of production
will be early February.
For sure we’ll continue with support, service and accessories
for the Zauri. Also there’re interesting other products around,
so the fun with mobile Linux products is definitely not over.


Marc Stephan

Gentoo on IBM ThinkPad 385XD

Another birthday present was a laptop IBM ThinkPad 385XD upgraded to 96MB of RAM and 10GB HDD.

It came with Windows 2000 preinstalled but I already build a Gentoo image on my desktop for it.


Due to the fact that it has a quite slow CPU and only 96 MB of RAM, I was thinking to use xfce as Desktop Manager. Then I thought that I should also try KDE because I had nothing to lose (except a few hours of compilation time on my desktop machine). So I emerged them both.

The conclusion is that KDE works like a charm on this machine. The whole system runs quite smoothly. I use distcc in combination with the x86 chroot of my desktop machine to emerge the new packages.

I had no problem to get a Surecom cardbus wifi card working with it using the rt2x00 driver provided by Gentoo.

Logitech Formula Force EX Wheel on Linux

On my birthday, my friends bought me a Logitech Formula Force EX Feedback Wheel. After playing with it a lot in Windows, I decided to make it work on Linux. The force feedback part didn’t work out of the box. I managed to make it work with the usb-hid driver after I added it’s usb id to it. You can find the patch against kernel 2.6.18 here.

  1. Copy the file to your kernel source root directory.
  2. Apply the patch:

    patch -p1 <logitech_formula_force_ex_ff.patch

  3. Recompile the usbhid module
  4. Reload the usbhid module.
  5. Have fun testing it with ffutils.

Logitech Formula Force EX Wheel

(Only the constant force effect works as this is the only effect currently implemented in the driver).

Romanian Demoscene Memories

When I was in highscool I was part of the Romanian demoscene subculture under the “PuthreGuy” nickname and I was part of the “General Failure” demogroup. I was also the SysOp of InfoVox BBS (FidoNet 2:531/10). “General Failure” was later renamed to “Float Entertainment” then to “Float|FX” when it merged with “Brain Damage” group. As of 1997, “General Failure” had 4 members:

PuthreGuy – code
Little Kopsha – code
PhM – music
Foaming Creature – code Continue reading

Bluetooth GPS on Gentoo

Configuring a Bluetooth GPS receiver on Gentoo was pretty straight forward for me.
This assumes that you already have the bluetooth stack up and running on your Gentoo box.

# emerge -p gpsd

# hcitool scan
Scanning …
00:0B:0D:6E:65:8A iBT-GPS
# sdptool browse 00:0B:0D:6E:65:8A
Browsing 00:0B:0D:6E:65:8A …
Service Name: SPP slave
Service Description: Bluetooth SPP V1.23
Service RecHandle: 0x10000
Service Class ID List:
“Serial Port” (0x1101)
Protocol Descriptor List:
“L2CAP” (0x0100)
“RFCOMM” (0x0003)
Channel: 1
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100

# rfcomm connect 0 00:0B:0D:6E:65:8A
Connected /dev/rfcomm0 to 00:0B:0D:6E:65:8A on channel 1
Press CTRL-C for hangup

On another terminal, start the gps daemon.

# gpsd /dev/rfcomm0

The fun begins:

# xgps