<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Pete&#039;s Blog</title>
	<atom:link href="http://infopete.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://infopete.wordpress.com</link>
	<description>Ramblings from a Marmite hater</description>
	<lastBuildDate>Fri, 18 Nov 2011 10:34:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='infopete.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Pete&#039;s Blog</title>
		<link>http://infopete.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://infopete.wordpress.com/osd.xml" title="Pete&#039;s Blog" />
	<atom:link rel='hub' href='http://infopete.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Decoding the Captured Signature</title>
		<link>http://infopete.wordpress.com/2009/06/09/decoding-the-captured-signature/</link>
		<comments>http://infopete.wordpress.com/2009/06/09/decoding-the-captured-signature/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 16:29:35 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Compact Framework]]></category>
		<category><![CDATA[Ordering]]></category>
		<category><![CDATA[Orders]]></category>
		<category><![CDATA[Signature]]></category>
		<category><![CDATA[Tracking]]></category>
		<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://infopete.wordpress.com/2009/06/09/decoding-the-captured-signature/</guid>
		<description><![CDATA[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 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=infopete.wordpress.com&amp;blog=6233104&amp;post=35&amp;subd=infopete&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>Add another Picturebox to the same form of the same size as the “Please Sign here” and call it PictureBox2.</p>
<p>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.</p>
<p>The following code takes the xy Hex coordinates and draws the pixels:</p>
<p>Dim lines() = DrawLines.Split(&#8220;,&#8221;)<br />
Dim xBit As Bitmap<br />
Dim g As Graphics<br />
Dim myPen As Pen = New Pen(Color.Black, 2)<br />
xBit = PictureBox2.Image</p>
<p>Dim cl As Color = Color.Black</p>
<p>g = Graphics.FromImage(xBit)</p>
<p>For Each line In lines<br />
    If line &lt;&gt; &#8220;&#8221; Then<br />
        sX = Integer.Parse(Mid(line, 1, 2), Globalization.NumberStyles.HexNumber)<br />
        sY = Integer.Parse(Mid(line, 3, 2), Globalization.NumberStyles.HexNumber)<br />
        For i = 5 To line.Length &#8211; 3 Step 4<br />
            eX = Integer.Parse(Mid(line, i, 2), Globalization.NumberStyles.HexNumber)<br />
            eY = Integer.Parse(Mid(line, i + 2, 2), Globalization.NumberStyles.HexNumber)<br />
            g.DrawLine(myPen, sX, sY, eX, eY)<br />
            sX = eX<br />
            sY = eY<br />
        Next<br />
    End If</p>
<p>Next<br />
PictureBox2.Image = xBit</p>
<p>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.</p>
<p>Now all is needed is some method of transmitting the signature from the mobile device to a server.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/infopete.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/infopete.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/infopete.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/infopete.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/infopete.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/infopete.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/infopete.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/infopete.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/infopete.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/infopete.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/infopete.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/infopete.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/infopete.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/infopete.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=infopete.wordpress.com&amp;blog=6233104&amp;post=35&amp;subd=infopete&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://infopete.wordpress.com/2009/06/09/decoding-the-captured-signature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/24a2809b0123e3733c5c3e4109801997?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">infopete</media:title>
		</media:content>
	</item>
		<item>
		<title>Signature Capture for Windows Mobile in Visual Basic</title>
		<link>http://infopete.wordpress.com/2009/05/06/signature-capture-for-windows-mobile-in-visual-basic/</link>
		<comments>http://infopete.wordpress.com/2009/05/06/signature-capture-for-windows-mobile-in-visual-basic/#comments</comments>
		<pubDate>Wed, 06 May 2009 16:35:47 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[Windows Mobile]]></category>
		<category><![CDATA[Barcode]]></category>
		<category><![CDATA[Ordering]]></category>
		<category><![CDATA[Sage]]></category>
		<category><![CDATA[Tracking]]></category>

		<guid isPermaLink="false">http://infopete.wordpress.com/2009/05/06/signature-capture-for-windows-mobile-in-visual-basic/</guid>
		<description><![CDATA[There are many examples of how to capture a signature on a Pocket PC device using either C# or Visual Basic. This post offers you a fast and easy way to capture a signature and generate the data ready to be sent to a server.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=infopete.wordpress.com&amp;blog=6233104&amp;post=27&amp;subd=infopete&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Over the past few years we have developed Windows Mobile applications that require a a signature to be recorded; either for a collection, a delivery or to indicate a customer is satisfied with a job.</p>
<p>There are several examples on how to do this in C# or Visual Basic but we’ve never been happy with the form of the data that gets sent back to the server. One of my colleagues had a requirement for a windows mobile application that recorded a signature and the signature was then viewable in a Silverlight application; this is how we did it.</p>
<p>This first post is only about the signature capture and the methods to convert a signature into a simple ascii string ready to be sent via a HTTP Post.</p>
<p><a href="http://infopete.files.wordpress.com/2009/05/signhere.png"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="sign here" src="http://infopete.files.wordpress.com/2009/05/signhere-thumb.png?w=224&#038;h=120" border="0" alt="sign here" width="224" height="120" align="left" /></a></p>
<p>First we start by creating a new project and adding a picturebox to the main form.  The “please sign here” image is then inserted into the picturebox as the default image.</p>
<p>To allow drawing on the picturebox (so we can make a signature) we only need to trap three events: MouseDown, MouseMove and MouseUp.</p>
<p>If we look at the following code:</p>
<p><span style="color:#0000ff;">Public Class Form1<br />
    Dim lastx As Int16<br />
    Dim lasty As Int16<br />
    Dim bit As Bitmap<br />
    Dim mdown As Boolean<br />
</span></p>
<p><span style="color:#0000ff;">Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
    bit = PictureBox1.Image</span></p>
<p><span style="color:#0000ff;">End Sub</span></p>
<p><span style="color:#0000ff;">Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown <br />
    mdown = True ‘ global boolean<br />
End Sub </span></p>
<p><span style="color:#0000ff;">Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove<br />
    Dim g As Graphics = Graphics.FromImage(bit)<br />
    Dim myPen As Pen = New Pen(Color.Black, 2) </span></p>
<p><span style="color:#0000ff;">    If mdown Then<br />
        g.DrawLine(myPen, lastx, lasty, e.X, e.Y) <br />
        PictureBox1.Image = bit ‘ bit is the bitmap of the picturebox defined as a global<br />
        lastx = e.X<br />
        lasty = e.Y </span></p>
<p><span style="color:#0000ff;">    End If<br />
End Sub </span></p>
<p><span style="color:#0000ff;">Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp<br />
    mdown = False ‘ global boolean<br />
    </span></p>
<p><span style="color:#0000ff;">End Sub</span></p>
<p><span style="color:#0000ff;">End Class</span></p>
<p>If you take this code and paste it into your project you’ll find you can now draw in the picturebox.</p>
<p>We now need to add the code to allow the signature to be sent via HTTP to a server.</p>
<p>We do this by capturing the “Drawline” coordinates and converting these into a HEX string.</p>
<p>First add two global strings to your project:</p>
<p><span style="color:#0000ff;">Public DrawLines As String = &#8220;&#8221;<br />
Public CurrentLine As String = &#8220;&#8221;</span></p>
<p>Then amend your MouseDown, MouseUp and MouseMove routines to be:</p>
<p><span style="color:#0000ff;">Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown<br />
    lastx = e.X<br />
    lasty = e.Y<br />
    CurrentLine = Hexit(e.X) &amp; Hexit(e.Y)<br />
    mdown = True<br />
End Sub </span></p>
<p>We record the mousedown xy coordinates and we also assign these values to the string CurrentLine, in Hex. Each Hex number is two characters long.</p>
<p><span style="color:#0000ff;">Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove<br />
    Dim g As Graphics = Graphics.FromImage(bit)<br />
    Dim myPen As Pen = New Pen(Color.Black, 2) </span></p>
<p><span style="color:#0000ff;">    If mdown Then<br />
        g.DrawLine(myPen, lastx, lasty, e.X, e.Y) </span></p>
<p><span style="color:#0000ff;">        CurrentLine = CurrentLine &amp; Hexit(e.X) &amp; Hexit(e.Y)<br />
        PictureBox1.Image = bit<br />
        lastx = e.X<br />
        lasty = e.Y </span></p>
<p><span style="color:#0000ff;">    End If<br />
End Sub </span></p>
<p>For each MouseMove we add the new xy coordinates to the CurrentLine in Hex.</p>
<p><a href="http://infopete.files.wordpress.com/2009/05/sig.png"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="sig" src="http://infopete.files.wordpress.com/2009/05/sig-thumb.png?w=157&#038;h=244" border="0" alt="sig" width="157" height="244" align="right" /></a></p>
<p><span style="color:#0000ff;">Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp<br />
    mdown = False<br />
    If CurrentLine.Length &gt; 4 Then<br />
        If DrawLines = &#8220;&#8221; Then<br />
            DrawLines = CurrentLine<br />
        Else<br />
            DrawLines = DrawLines &amp; &#8220;,&#8221; &amp; CurrentLine<br />
        End If<br />
    End If </span></p>
<p><span style="color:#0000ff;">End Sub</span></p>
<p>When we finish the line we are drawing we append the CurrentLine to DrawLines and separate each line with commas so we end up with a CSV line.</p>
<p>And add the following simple HEX conversion function to your project:</p>
<p><span style="color:#0000ff;">Private Function Hexit(ByVal v As Integer) As String<br />
    Hexit = Hex(v)<br />
    If Hexit.Length = 1 Then Hexit = &#8220;0&#8243; &amp; Hexit<br />
End Function</span></p>
<p>Add a textbox to your Form and make it multiline and add vertical scrollbars. And a single MenuItem:</p>
<p><span style="color:#0000ff;">Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click<br />
    TextBox1.Text = DrawLines<br />
End Sub</span></p>
<p>That’s all it takes to capture a signature and convert it to an ascii string that is easy to understand, easy to transmit and is reasonably efficient in space. Oh and it runs fast too.</p>
<p><span style="color:#0000ff;"> </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/infopete.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/infopete.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/infopete.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/infopete.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/infopete.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/infopete.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/infopete.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/infopete.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/infopete.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/infopete.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/infopete.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/infopete.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/infopete.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/infopete.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=infopete.wordpress.com&amp;blog=6233104&amp;post=27&amp;subd=infopete&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://infopete.wordpress.com/2009/05/06/signature-capture-for-windows-mobile-in-visual-basic/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/24a2809b0123e3733c5c3e4109801997?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">infopete</media:title>
		</media:content>

		<media:content url="http://infopete.files.wordpress.com/2009/05/signhere-thumb.png" medium="image">
			<media:title type="html">sign here</media:title>
		</media:content>

		<media:content url="http://infopete.files.wordpress.com/2009/05/sig-thumb.png" medium="image">
			<media:title type="html">sig</media:title>
		</media:content>
	</item>
	</channel>
</rss>
