I was recently asked how to decode the signature from the Hex strings in my previous post “Signature Capture for Windows Mobile”, so here goes.

Add another Picturebox to the same form of the same size as the “Please Sign here” and call it PictureBox2.

The output of the captured signature is a Hex string stored in the variable “Drawlines”; this is effectively a comma delimited series of xy pixel coordinates.

The following code takes the xy Hex coordinates and draws the pixels:

Dim lines() = DrawLines.Split(“,”)
Dim xBit As Bitmap
Dim g As Graphics
Dim myPen As Pen = New Pen(Color.Black, 2)
xBit = PictureBox2.Image

Dim cl As Color = Color.Black

g = Graphics.FromImage(xBit)

For Each line In lines
    If line <> “” Then
        sX = Integer.Parse(Mid(line, 1, 2), Globalization.NumberStyles.HexNumber)
        sY = Integer.Parse(Mid(line, 3, 2), Globalization.NumberStyles.HexNumber)
        For i = 5 To line.Length – 3 Step 4
            eX = Integer.Parse(Mid(line, i, 2), Globalization.NumberStyles.HexNumber)
            eY = Integer.Parse(Mid(line, i + 2, 2), Globalization.NumberStyles.HexNumber)
            g.DrawLine(myPen, sX, sY, eX, eY)
            sX = eX
            sY = eY
        Next
    End If

Next
PictureBox2.Image = xBit

I’ve used a Picturebox simply because it’s easy to see the resulting signature but it’s more likely you will use a bitmap and create a jpeg or png and save the result as an image.

Now all is needed is some method of transmitting the signature from the mobile device to a server.