Page 1
Page 2
Digital Signature Capture
Sooner or later anyone involved in enterprise
level development for the Pocket PC is going to be asked
about digital signature capture. There's no denying that
it's a powerful feature for applications that requires some
form of authorisation - whether it's the customer's signature
on an order form, or an engineer signing off a vehicle as
being roadworthy.
Let's keep things simple though. We're
not talking here about any form of advanced signature analysis
or verification, all we want is a method of storing and
retrieving a copy of whatever the user signs in a SIP sized
240x80 box.
Taking a field sales system as an example,
lets skip how you get a signature on the screen and just
look at the end result. You have just finished building
a new order and the data is safely stored in an ADOCE database,
the customer then signs the order confirmation screen. You're
left with a screen containing some graphics representing
a signature, so how are you going to store it?
The easiest sounding solution would
be to insert the bitmap image into the database along with
the order data. Unfortunately there's no binary datatype
using ADO, but that's just the start of your problems. Do
you really want to add 19200 bytes of data for each signature?
What about synchronisation speed? Will the target machine
reading the data have the same image format or will you
have to convert it?
These problems could be solved, but
there is a better way. It starts by realising that a signature
is simply a set of lines.
Capturing the image
When signing the screen your stylus
makes contact at one set of coordinates, moves about a bit,
and is then released. We can use this knowledge in conjunction
with the PictureBox control to create a simple signature
capture system. Below is some cut-down code for each event:
Sub PictureBox_MouseDown(x As Double,
y As Double)
OldX = x
OldY = y
End Sub
Sub PictureBox_MouseMove(x As Double,
y As Double)
PictureBox.DrawLine OldX, OldY, x, y
OldX = x
OldY = y
End Sub
It's really that simple! As soon as
the stylus touches the PictureBox the coordinates
are stored, then as the stylus moves lines are drawn between
the current position and the last known position. Couldn't
be easier.
Depending on the complexity of the signature,
between 150 to 300 line segments will be needed to make
up the final vector image. With such a small amount of data
this looks like the ideal method of capture, we just need
a way to store it.
It's a numbers game
Ok, so we know we need to store a number
of vector lines each consisting of a number of segments.
Lets look at the data.
To maintain a consistent user interface
we chose the PictureBox control to be the same size as a
standard SIP box, 240 x 80 pixels. So our X coordinate
range is from 0 to 239, and our Y coordinate range is from
0 to 79. An 8-bit unsigned byte (no pun intended) has the
range 0 to 255, which just works for the X axis and is more
than adequate for storing the Y axis.
Since our vector signature will consist
of different segments we will need to know when a line starts
and finishes. Fortunately the Most Significant Bit
of the bytes used to represent Y coordinates will never
be used, let's take advantage of that.
Next Page