Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4android > Basic4android Getting started & Tutorials
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Basic4android Getting started & Tutorials Android development starts here. Please do not post questions in this sub-forum.

Signature Capture Tutorial

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2011, 09:36 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default Signature Capture Tutorial

Several developers were interested in adding support for signature capturing in their Android application.
The attached code module makes it easy to capture the signature and save it to a file.



You should create a layout similar to the above layout.
The drawing is done on a Panel view.

Load the layout (or create it programmatically), initialize the canvas object which does the actual drawing and initialize the SignatureData object:
Code:
Sub Globals
    
Dim Panel1 As Panel
    
Dim Canvas1 As Canvas
    
Dim SD As SignatureData 'This object holds the data required for SignatureCapture
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout(
"1")
    Canvas1.Initialize(Panel1)
    SD.Initialize
    SD.Canvas = Canvas1
    SD.Panel = Panel1
    SD.SignatureColor = 
Colors.Black
    SD.SignatureWidth = 
5dip 'Stroke width
End Sub
Add events for the panel Touch event and for the buttons. These events call the SignatureCapture module.
Code:
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    SignatureCapture.Panel_Touch(SD, x, y, Action)
End Sub
Sub btnSave_Click
    SignatureCapture.Save(SD, 
File.DirRootExternal, "sign.png")
    
ToastMessageShow("Signature saved to: " & File.Combine(File.DirRootExternal, "sign.png"), True)
End Sub
Sub btnClear_Click
    SignatureCapture.Clear(SD)
End Sub
That's it.
Attached Files
File Type: zip SignatureCapture.zip (6.4 KB, 416 views)
Reply With Quote
  #2 (permalink)  
Old 05-15-2011, 12:43 PM
Newbie
 
Join Date: Apr 2011
Posts: 2
Default

Wow! excelent. Just what I need.
Thank you Erel
Reply With Quote
  #3 (permalink)  
Old 05-16-2011, 08:52 AM
Junior Member
 
Join Date: Mar 2011
Posts: 15
Default

Hi Erel,

Thanks for those great tuts.

Is there a way to capture en store the points of the signature? instead of a picture?

Thanks in advance!

TheDevMan
Reply With Quote
  #4 (permalink)  
Old 05-16-2011, 09:42 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You can change the code and store the points together with drawing the lines.
Reply With Quote
  #5 (permalink)  
Old 07-04-2011, 02:40 PM
Newbie
 
Join Date: Jul 2011
Posts: 1
Default zip file

Hi

That is what I really need, but I cannot save the file.
is it free? How can I access to the code.

Best,
Golnoosh
Reply With Quote
  #6 (permalink)  
Old 07-04-2011, 02:43 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Have you purchased Basic4android? If yes then contact support@basic4ppc.com to fix this issue. This file is only available to licensed users.
Reply With Quote
  #7 (permalink)  
Old 09-30-2011, 03:37 PM
Basic4ppc Veteran
 
Join Date: Dec 2010
Location: Colorado, USA
Posts: 204
Default Signature Capture resolution

Erel,
I have written a signature capture program and find that the points I capture are far apart. Is there a way to set the frequency the Panel_Touch event is fired? The points I capture are too far apart and I want to get smoother lines as opposed to angular straight lines.
Thanks,
Reply With Quote
  #8 (permalink)  
Old 10-02-2011, 06:30 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Are you using this code module?
There is no way to modify the frequency of the touch event. Make sure that you are not doing anything too heavy when handling this event.
Reply With Quote
  #9 (permalink)  
Old 10-03-2011, 02:43 AM
Basic4ppc Veteran
 
Join Date: Dec 2010
Location: Colorado, USA
Posts: 204
Default

Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
SignatureCapture.Panel_Touch(SD, x, y, Action)
If SignPt < SignPoints.Length -1 Then
SignPoints(signPt).x = x
SignPoints(signPt).y = y
SignPt = SignPt + 1
End If
End Sub
The only thing I'm doing differently is I have a type array SignPoints and a pointer variable signPt where I record the touch location each time it changes. I've limited the array size to 1000 points and rarely get to 180 points on a fairly complex signature. If the user draws a circle slowly, it creates a jagged circle. If he does it fast, it might be a straight line. I digitize it so I don't have to store an image. Yes, I'm using your code module in the signaturecapture code, unchanged.
Ideas are appreciated. Thanks,
Reply With Quote
  #10 (permalink)  
Old 10-04-2011, 07:28 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Which device are you using?
I've just tested it and it draws quite smoothly even when I draw very quickly.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen Capture App sahoopes Share Your Creations 5 10-06-2011 07:22 AM
Electronic signature cn212 Basic4android Updates and Questions 5 04-26-2011 09:19 AM
wish Audio Capture slydog43 Bugs & wishlist 1 03-12-2011 07:49 AM
Intermittent error (unexpected signature) mistermentality Basic4android Updates and Questions 2 03-02-2011 12:49 PM
Signature capture and label autosize ohkovar Questions (Windows Mobile) 10 02-06-2010 09:30 AM


All times are GMT. The time now is 10:42 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0