Click here to Skip to main content
15,890,438 members
Articles / Mobile Apps / Windows Mobile

Scratchpad/Signature Capture as BMP on Pocket PC

Rate me:
Please Sign up or sign in to vote.
4.71/5 (19 votes)
6 Sep 2006CPOL2 min read 187.2K   2.8K   56   65
A way to capture signature or scribble on the Pocket PC.

Sample Image - SignaturePPC02.gif Sample Image - SignaturePPC02.gif

Sample Image - SignaturePPC02.gif

Introduction

This control class allows a user to take a colored jot down note or signature, and save it as BMP file in the Pocket PC. This easy to use code can be plugged into any .NET application to take scribbles.

Background

Quite for a long time, I was looking for a free Signature control or some thing like that, that I could use in my own application without overloading it with bulkier codes. I was looking for some thing where I could change the pen color, width, and so on. In the internet knowledge bases, there was very few information on this, and most did not suit my needs. Later, I thought of assembling the available code and stripping down the un-needed portions, and fine-tuning the code to the level of my expectations.

Thought, may be a few people like me are still looking for this kind of a snippet and thought of sharing it. There are a few portions in this code that a programmer can even modify, like make the pen width changeable, save image as JPG or GIF etc.

Using the code

Copy the Signature.cs file to any of your Pocket PC 2003 projects. Add a Panel control to the visual form. Put this code as described and get the project rolling with signature capture capability.

Here, I have added a Panel:

C#
private System.Windows.Forms.Panel pnlSignature;
private Signature cSignature;

Later in the constructor, or in the form Load event, you can add:

C#
cSignature = new Signature();
cSignature.Location = pnlSignature.Location;
cSignature.Size = pnlSignature.Size;
this.pnlSignature.Visible = false;
this.Controls.Add(cSignature);

Under any Button's Click event, you can write this code to save the file under your desired location with a name:

C#
cSignature.Save(Path.Combine(AppPath, "CapturedPicture.bmp"));

Similarly, you can change the pen color by calling:

C#
cSignature.SetPenColor(Color.Blue);

or load a previously saved picture of the same size, using:

C#
cSignature.LoadImage(Path.Combine(AppPath, 
        "PreviouslyCapturedPicture.bmp"));

Tips and Tricks:

  1. Do not forget to set the Visibility of the Panel to false, as we need to see the control, not the Panel. Here, the Panel is just a container.
  2. It is more important to set the size of the signature control to the size of the loaded picture and the Panel size, else it may not work.

Points of Interest

While working on this, I changed the pen width by changing the following lines of code. Obviously, there must be a better way to do this than what I did.

C#
GraphicsHandle.DrawLine(SignaturePen, l.StartX+1, 
                      l.StartY, l.EndX+1,l.EndY);
GraphicsHandle.DrawLine(SignaturePen, l.StartX, 
                  l.StartY+1, l.EndX,l.EndY+1);
GraphicsHandle.DrawLine(SignaturePen, l.StartX+1, 
                  l.StartY+1, l.EndX+1,l.EndY+1);
GraphicsHandle.DrawLine(SignaturePen, l.StartX, 
                      l.StartY, l.EndX,l.EndY);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Rajesh Nayak currently working with CSDC Systems Inc.'s (canada East Zone - R&D Branch) as Product Manager-Mobile Solutions.

Comments and Discussions

 
GeneralRe: it is not working in VS.net 2005 Pin
RajeshNayak6-Sep-06 10:14
RajeshNayak6-Sep-06 10:14 
AnswerRe: it is not working in VS.net 2005 Pin
RajeshNayak6-Sep-06 10:12
RajeshNayak6-Sep-06 10:12 
GeneralRe: it is not working in VS.net 2005 Pin
Rothariger6-Sep-06 13:28
Rothariger6-Sep-06 13:28 
Questiontransparent Pin
vitdotnet27-Jun-06 19:50
vitdotnet27-Jun-06 19:50 
AnswerRe: transparent Pin
ArnoldTang2-Jul-06 17:22
ArnoldTang2-Jul-06 17:22 
Generalheight x weight x bitcount Pin
ArnoldTang16-May-06 0:35
ArnoldTang16-May-06 0:35 
GeneralRe: height x weight x bitcount Pin
hashill30-May-06 4:30
hashill30-May-06 4:30 
GeneralRe: height x weight x bitcount Pin
ArnoldTang2-Jul-06 17:20
ArnoldTang2-Jul-06 17:20 
GeneralRe: height x weight x bitcount Pin
RajeshNayak30-May-06 5:43
RajeshNayak30-May-06 5:43 
GeneralQuery Pin
makarandg22-Feb-06 2:00
makarandg22-Feb-06 2:00 
JokeRe: Query Pin
RajeshNayak27-Mar-06 14:58
RajeshNayak27-Mar-06 14:58 
QuestionMono BMP Pin
Handheld Programmer14-Feb-06 5:02
Handheld Programmer14-Feb-06 5:02 
AnswerRe: Mono BMP Pin
vwiggin10-Mar-06 3:17
vwiggin10-Mar-06 3:17 
GeneralRe: Mono BMP Pin
RajeshNayak27-Mar-06 14:49
RajeshNayak27-Mar-06 14:49 
GeneralRe: Mono BMP Pin
anschutz15-Oct-06 13:09
anschutz15-Oct-06 13:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.