TMSFNSSignatureCapture LoadFromStream/File causes 'Out of Memory' error

When saving a signature I use SaveToImageFile to create the png image of the signature and then LoadFromFile to save to a database blob field. That part works Ok.

Now if I need to display a saved image back to the SignatureCapture component I get an 'Out of Memory' error. Have tried both LoadFromStream by using SaveToStream from the database field and LoadFromFile using the png file previously created. In both instances I get the same error. The png file is only 6.9k in size. Below is code I use with SaveToStream:

            msImage := tMemoryStream.Create;
            try
              MarafillerDM.EMUInvQrySIGNATURE.SaveToStream(msImage);
              EMUSig.LoadFromStream(msImage);
            finally
              msImage.Free;
            end;

Any assistance would be appreciated.

Bill Zwirs

Hi,

We are unable to reproduce this.
Which framework are you using? Which IDE version do you have?

try this:

  msImage := tMemoryStream.Create;
  try
    MarafillerDM.EMUInvQrySIGNATURE.SaveToStream(msImage);
    msImage.Positioin := 0;  // <<< add
    EMUSig.LoadFromStream(msImage);
  finally
    msImage.Free;
  end;

Even with msImage.Position := 0 added, the component still works as expected here.
Are you working with FMX, VCL, LCL or WEB? What is your IDE version?

Tried msImage.Position := 0 but made no difference.

Using:
Delphi 11.1
FMX
SignatureCapture Version 1.0.1.0

Bill

We tested with Delphi 11.1 in an FMX project with Windows target but we could not reproduce this issue.

What is your target? Windows, macOS, Android, iOS or Linux?

Are MarafillerDM.EMUInvQrySIGNATURE and EMUSig both TTMSFNCSignatureCapture controls?
Did you customize the settings of your TTMSFNCSignatureCapture in some way?

EMUSig is the SignatureCapture control
MarafillerDM.EMUInvQry is a FireDac query....Signature is a blob field in a SQLite database table.

Target is Windows and Android

Below is settings from .fmx file

object EMUSig: TTMSFNCSignatureCapture
              Position.X = 96.000000000000000000
              Position.Y = 51.000000000000000000
              Size.Width = 537.000000000000000000
              Size.Height = 265.000000000000000000
              Size.PlatformDefault = False
              TabOrder = 0
              Font.Name = 'Segoe UI'
              Pen.Color = claBlack
              Pen.Width = 3.000000000000000000
              TextPosition.Line.Color = claGray
              ClearSig.Image.PNG = {
                89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
                F8000000017352474200AECE1CE90000000467414D410000B18F0BFC61050000
                01ED49444154484BD555CB550241109CD58BC70D81A3478C80210388408C4089
                6097082403F6E65189408840BC794323900CB0AAA767DECEEEB0C2E344BDB7AF
                677AE8EAAE9E0FE6E291A9354551F4B22C7BC630DFEFF74BD86A369BED64F10C
                5CA9354A3EC26739C6B745D25216CF40505096E52B0C1334B181A2E1B16A5054
                0E233C88A98202904C6152247D55D3D7791258B7287281DFFEE27B846B457F50
                40E83E5049920C453CB02A9D0A103341CC3D86D679CC1C8958AC204AE081A012
                41854E23F824AC18BF59C0D5732BE65BD7A4728F640202046C0D09526A36F8EA
                FE39C8C1DDDEA783093CBAD400C9AAEB089B7C08082E4132D46913AB2E72E25A
                ED4140C1080A5E30BC719E08FDC160F0B35EAFD9B2243A15E034F0C2F154F16C
                13ECF19B1B3A709FB85F3A6D2199000139C83F307C721EC18EAD827FCCBEAB4F
                C02218A3D308AD04AC06015B0CEB550939FA2DAD80AD1A49787F78E25A88F640
                C9DF31AC5713917BB0EFD65ADE015FC82DF6E313FE2F9D0BC2310539AB605B22
                A9201F833CEA7B1D7C1E60266E26C7F60EBF0FF721B4482536C9A75DE40412B0
                55FEF96091D19D1105DA1A565F47A5C147A1AE4455484BBD82E6337D123941B5
                30428A62F9DF22F00928D1F78DAFE149E404FB8E24BCF14C62D115795DFF7D8B
                4E058873DD871E0A1D3BEFE5C2983FE2BEE02B964D075A0000000049454E44AE
                426082}
            end

Now it's more clear. From your initial question it looked like you were trying to save from one TTMSFNCSignatureCapture to another.

You cannot combine saving to an image and loading from a stream. When loading from a stream it is expected the stream will be a stream produced by TTMSFNCSignatureCapture. This is because the stream produced by TTMSFNCSignatureCapture contains the coordinate points, color, etc... for the signature, so it's incompatible with image formats.

There are 2 things you can do:

  1. If signature image storing is not a must, then you can use SaveToFile instead of SaveToImageFile. This should produce a file that is compatible with the stream loading mechanism.
  2. If it's important for you to keep the signature as an image too, then we'd suggest adding an extra DB field where you'll store the signature stream and use that field to load the signature back.

Tunde,

Thanks for your quick response which has also helped me understand your component a little better. When I get the time...I think that I will go with option 2.

thanks again

Bill