Search code examples
c#topaz-signatures

Problems retrieving signature using Topaz Systems Signature Pad


I've been working on this problem for a while, I have a Topaz Signature Pad I'm using to capture signatures from users as they use the application I'm currently developing. I'm using the standard demo app that Topaz supplies to do this (https://topazsystems.com/Software/sigplusnet_csharp_wpfsimpledemo.zip)

I'm retrieving the signature string ok, I can save it to the database (Microsoft SQL Server 2019); but when I try to pull it back out to reconstruct the signature I can't figure out how to do it.

I decided to try the 'GetSigImage()' method, but I get weird errors with that too See below:

public ImageSource v;

sigPlusNET1.SetTabletState(0);

// Encrypt the signature.
sigPlusNET1.AutoKeyStart();
sigPlusNET1.SetAutoKeyData("123");
sigPlusNET1.AutoKeyFinish();
//sigPlusNET1.SetEncryptionMode(2);

//sigPlusNET1.SetSigCompressionMode(1);

// This is the Topaz format SigString that can be stored for future use.
v = GetImage(sigPlusNET1.GetSigImage());

the error I get is:

'Parameter is not valid.'

on the line of:

v = GetImage(sigPlusNET1.GetSigImage());

My GetImage() Method is:

private ImageSource GetImage(Image source)
    {
        using (var ms = new MemoryStream())
        {
            source.Save(ms, ImageFormat.Bmp);
            ms.Seek(0, SeekOrigin.Begin);

            var bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.StreamSource = ms;
            bitmapImage.EndInit();

            return bitmapImage;
        }
    }

I'm not sure what I'm doing wrong or not thinking of. Any help anyone can offer would be greatly appreciated


Solution

  • Found the answer in another demo that Topaz put out. Figured I'd put it here just in case anyone has the same problem.

    You have to set parameters for the image before you can save or retrieve it as an image. I'm pasting the code below.

    sigPlusNET1.SetImageXSize(1000);
    sigPlusNET1.SetImageYSize(300);
    sigPlusNET1.SetJustifyY(10);
    sigPlusNET1.SetJustifyX(10);
    sigPlusNET1.SetJustifyMode(5);
    sigPlusNET1.SetImagePenWidth(10);
    sigPlusNET1.SetImageFileFormat(4); //0=bmp, 4=jpg, 6=tif
    sigimage = sigPlusNET1.GetSigImage();