signature control to byte array and back

  • Thread starter Thread starter Florian Lutz
  • Start date Start date
F

Florian Lutz

Hi,

how do i create a bitmap on a pocketpc device form a byte[] ? the
problem is i use the opennetcf signature control and get the byte[]
with signature.GetSignature(). I tried to create an image with:

MemoryStream memStream = new MemoryStream(sig_array);
pictureBox1.Image = new Bitmap(memStream);

but i throws a ArgumentException. it seems it can't create the image
from the byte array.

thanks,

Florian Lutz
 
okay thats a problem with the control but my question remains:
how do i convert a bitmap to a byte array so i can store it in a
dataset ?
 
I used the same general structure as in the sample and had no problems at
all:

Dim BitmapBytes As Byte() = SignatureCapture1.SaveToByteArray()
dr("Signature") = BitmapBytes
 
strange... what signature control are you using? The one from the
opennetcf framework or another one? i am very interested, since i have
to include a signature applet in my code.
how would you get the image back from the datarow?

thanks,

florian
 
Ahhh ... well, now I used the one from HoodCanal systems. I was under the
impression those were the same, but you might want to take a look over
there.
 
Florian,

I store signatures from the OpenNetCF control to a file like this:

if(signature1.GetSignature() != null)
{
byte[] signatureBytes = signature1.GetSignature();
FileStream fs = new FileStream("test.bmp", FileMode.Create);
BinaryWriter writer = new BinaryWriter(fs);
writer.Write(signatureBytes);
writer.Close();
fs.Close();
signature1.Clear();
}


and I load them back like this:

FileInfo fi = new FileInfo("test.bmp");
if(fi.Exists)
{
FileStream fs = new FileStream("test.bmp", FileMode.Open);
BinaryReader reader = new BinaryReader(fs);
byte[] bytes = reader.ReadBytes((int)fi.Length*4);
reader.Close();
fs.Close();
signature1.LoadSignature(bytes);
}

You would just modify the code that reads and writes to a file to store or
load the byte[] from your data.
 
thanks for the answers! hmm i get a bitmap file. but it not a "real"
bitmap file, is it? if i try to open it, it seems to be empty. is there
a way to get a "real" one?
 
Back
Top