Converting Hypercom/Symbol sig format signature data to png image with PHP

As part of my ongoing paperless form project I need a way to display signatures captured by the Hypercom L5300 device. Equinox (formerly HyperCom) sent me a PDF describing the format for the sig data. There was one detail they left out...draw command x and y values were described as a sign plus 5 bits of value. I do not deal directly with bits often so I did not realize the values were stored in two's complement.

Some back and forth emails and finally one of them stated the two's complement storage. Small fix to my code and everything worked. I'll upload the code later. (now uploaded)

[EDIT] 2012-09-04 11:38AM
The code is now attached to this post. To use it simply pass the binary signature data from the terminal. (The terminal often returns base64 encoded data so be sure to decode.)

$base64_sig = [data from terminal];
$bin_sig = base64_decode($base64_sig);
$signature = new sigConvert($bin_sig);
$signature->convertToDG(); // create a GD canvas and draw the signature on it
$signature->savePNG("image.png", false); // save full size image
$signature->savePNG("image-cropped.png",true); //save just the cropped signature
$signature->getScaledPNG(500,200); // output a scaled (and cropped) PNG image of the signature