Page 1 of 1

JQMSignature SaveAsImage not consistent

PostPosted: 18 Oct 2016 01:31
by dfields
I have been trying to use JQMSignature, but am unable to get consistent results. I am trying to capture the signature as an image by following the demo. It works about 30% of the time. Most time it will not output any file at all.

1. If the file already exists, it is not overwritten. There are no options to override this behavior.

2. If any file is created, you cannot read it back into the application. I want to bring it into a BLOB field, but anytime I try to read the file I get an access violation because it could not find the file.

3. I would rather save to a stream and skip the file entirely, but I cannot see any methods for that. Am I missing something?

Re: JQMSignature SaveAsImage not consistent

PostPosted: 18 Oct 2016 17:29
by zsleo
I also stuggled with this for too long...

http://www.cgdevtools.com/cgforum/viewtopic.php?f=67&t=3066

I agree that a streamed methods would be great to have along with database interface.

That said, the only way I could get saving and loading images to work correctly was to redesign my app to generate a new uniquely named image for every use of an image.

Thanks to Alexander "CGGenAutoID" has become my new best friend.

Hope this helps

Re: JQMSignature SaveAsImage not consistent

PostPosted: 18 Oct 2016 21:29
by dfields
I could not tell from the post you referenced. Did you ever get it to work?

Re: JQMSignature SaveAsImage not consistent

PostPosted: 19 Oct 2016 16:47
by Alexander Bulei
Hi dfields,

You can handle the saving by your self, by using :
  • OnSaveToStream - This event will be called when the image is sucessfully sent to server, when calling SaveAsImage
  • OnFileSaved - This event will be called when the image is sucessfully saved, when calling SaveAsImage

Best Regards.

Re: JQMSignature SaveAsImage not consistent

PostPosted: 19 Oct 2016 19:43
by zsleo
Sorry for not being clear. Yes. I have it working perfectly for my use - and fully interfaced to MS SQL.

As for the link look at my post under the image component but I had the problem with both image and signature. Both now working for me.

Finally. Alexander, thanks for your help but I do wis these for these two components to be working by direct interface to DB without manipulating though streams or files. That stated I am very happy with what I now have working.
:D
Regards.

Re: JQMSignature SaveAsImage not consistent

PostPosted: 19 Oct 2016 23:13
by dfields
So where do I use that method? Here is what I tried without success (below). I never get to DoOnSaveToStream. Are there other properties to set?

Code: Select all
//this happens in a button event
Signature1.OnSaveToStream := DoOnSaveToStream;
Signature1.SaveAsImage(fn);

procedure TFormSmartphoneSignature.DoOnSaveToStream(Sender: TObject; const AFileName: string; AStream: TStream);
begin
  with UserSession do
  begin
    ProxyData.Edit;
    TBLOBField(ProxyData.FieldByName('MemberSignature')).LoadFromStream(AStream);
    ProxyData.Post;
  end;
end;

Re: JQMSignature SaveAsImage not consistent

PostPosted: 21 Oct 2016 11:48
by Alexander Bulei
Hi dfields,

//this happens in a button event
Signature1.OnSaveToStream := DoOnSaveToStream;
Signature1.SaveAsImage(fn);


Code: Select all
Signature1.OnSaveToStream := DoOnSaveToStream;


Do nothing in async...
Assign the event on form/frame create...

Best Regards.

Re: JQMSignature SaveAsImage not consistent

PostPosted: 21 Oct 2016 22:43
by dfields
I tried that first, but it still does not work. Either way the breakpoint I set in that procedure is never reached. Now, I cannot get it to save a file at all. What am I missing?! This seems like such a simple task. Can you point me to a working example, or even post some complete code that I can follow?

Re: JQMSignature SaveAsImage not consistent

PostPosted: 24 Oct 2016 14:39
by Alexander Bulei
Hi dfields,

delphi code
procedure TIWAppForm6.IWAppFormCreate(Sender: TObject);
begin
IWCGJQMSignature1.OnSaveToStream:= OnSaveImage;
end;

procedure TIWAppForm6.IWCGJQMButton1JQMButtonOptionsEventsVClick(Sender: TObject; AParams: TStringList);
begin
IWCGJQMSignature1.SaveAsImage('test.png');
end;

procedure TIWAppForm6.OnSaveImage(Sender: TObject; const AFileName: string; AStream: TStream);
begin
sleep(0); // PUT BREAKPOINT HERE
end;


Best Regards.