Pocket PC 2003 : Saving the signature as a bitmap
The Compact Framework supports only a subset of the graphical output features of the Desktop Framework. You can do all of the more commonly required text drawing operations such as selecting different fonts by name, in different sizes and styles, and also control the color of drawn text.
But this is a small price to pay for the small memory footprint occupied by the Compact Framework.
The System.Drawing.Graphics namespace is commonly used for almost any forms in the desktop framework, hence it has got lots of facilities to draw any kind of image on to the device context. However this namespace in the smaller version of the framework or the compact framework as It is commonly called is having only a very few classes/functionalities.
However there are means to overcome these short comings by making use of the win32 functions readily available/provided to the compact world.
Problem at hand: A Route sales Representative of Company A carries out a order/ sales for one of his prominent client (say for Wal-Mart) and after delivering the goods to his client he comes with his Pocket PC to take a signature from him for the delivery made. We will now try to save the signature captured as a bitmap for later reference and for validation.
Diagram 1: Signature Capture
Let us see how we can capture and save this signature captured as a bitmap.
Steps to be followed:
- Create a smart device application.
- Add labels and the panel where the signature is to be done.
- Add a Panel (areaSignature) which will specify the location and size of the signature control.
_signature = new SignatureControl();
_signature.Location = areaSignature.Location;
_signature.Size = areaSignature.Size;
- Add this signature Control to the main Panel of the form.
- On clicking Save this signature image needs to be stored as a bitmap for future reference or for verification.
GenBitmap.Snapshot(pnlCaptureSign, @"\Program Files\GenSignature\GenSign" +BmpCnt+".bmp");
GenBitmap is the class which implements the user defined method Snapshot.This method basically stores the info from the control into the bitmap header structures and finally transfers the data bits into a file with the extension as .bmp.
We have to basically make use of the win32 functions from coredll for implementing this feature in Compact framework.
Attached is also the code with the implementation of the method Snapshot which gives you the solution to the problem.
For any queries related to this please mail to [email protected]
Name: Pinto Philip (MCSD.NET)
Senior Software Engineer
Mail: [email protected]
Other white papers written by the author:
Rotating the text display on a Pocket PC/Win CE device
URL : http://www.c-sharpcorner.com/Code/2005/Feb/RotateText_WinCE.asp
Simplifying Remoting in .Net
URL : http://msd2d.com/Content/Tip_viewitem.aspx?section=dotNet&id=0acc3ac3-927f-421c-84a0-b8827b11ce65
Working with Check boxes in Data Grid