Saving Signature to Bitmap

S

Scott Toney

I tried to save the signature box to a bitmap file using the getsignatureex,
filestream create and binary writer, so that I could print it and I am
getting a file that is not recognized as a bitmap. I am trying to do this in
VB. Can anyone tell me what I am doing wrong?
Code:

If (Not (Signature1.GetSignatureEx()) Is Nothing) Then
Dim signatureBytes() As Byte
signatureBytes = Signature1.GetSignatureEx()
Try
Dim fs As FileStream
fs = New FileStream("R1.bmp", FileMode.Create)
Dim writer As BinaryWriter = New BinaryWriter(fs)
writer.Write(signatureBytes)
writer.Close()
fs.Close()
Catch ioerror As IOException
MessageBox.Show(ioerror.ToString + " " + ioerror.InnerException.Message)
Catch er As Exception
MessageBox.Show(er.ToString)
End Try
'Signature1.Clear()
End If

Thanks

Scott
 
G

Ginny Caughey [MVP]

Scott,

I'm using this sample to capture signatures:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/PPCSignatureApp.asp

It works by collecting points in a MouseMove event handler. When you're
ready to write the points out as a BMP file the code looks like this:

FileStream fs = new FileStream(BmpFileName, FileMode.Create);
Bitmap bitmap = sigControl.Bmp;
bitmap.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
fs.Close();

I actually save my signatures as PNG files since they are much smaller on
the device, but you can get BMP files by specifying ImageFormat.Bmp.
 
S

Scott Toney

Thanks for the reply, but I must be missing something. Using the
PPCSignatureApp and then the code you added:

FileStream fs = new FileStream(BmpFileName, FileMode.Create);
Bitmap bitmap = sigControl.Bmp;
bitmap.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
fs.Close();

The line:
bitmap.Save(fs, System.Drawing.Imaging.ImageFormat.Png);
errors and says that save is not a member of System.Drawing.Bitmap
 
G

Ginny Caughey [MVP]

Scott,

Which version of the Compact Framework are you using? I just lifted the code
from a production app.
 
S

Scott Toney

Version 2 on a WM5 iPaq, vs2003

Ginny Caughey said:
Scott,

Which version of the Compact Framework are you using? I just lifted the code
from a production app.
 
G

Ginny Caughey [MVP]

Scott,

Are you using VS 2003? You need VS 2005 to use CF 2. Perhaps that is the
problem?
 
S

Scott Toney

I was afraid you were going to say that. :)
Thats what I'll be doing the next few days.
Thanks
Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top