Jump to content

htmlframe-canvas to unimimage


ice

Recommended Posts

Hi,

i make a canvas in unimhtmlframe and make a signatue-script in javascript.

unimhtmlframe: <canvas id="signatur">

javascript:(signatur.js) by addjs. it work.

now i like to save it to database.

my idee is too put it in a unimimage and save it to a database.

Link to comment
Share on other sites

Hi,

 

Try.. exemplary implementation:

 

1.

uses ... Soap.EncdDecd;

2.

procedure TMainmForm.UnimButton1Click(Sender: TObject);
begin
  UniSession.AddJS('ajaxRequest('+ UnimImage1.JSName +', "_img", ["_src="+document.getElementById("signatur").toDataURL()])');
end;

3.

procedure TMainmForm.UnimImage1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  stream: TBytesStream;
  base64s: string;
begin
  if EventName = '_img' then
  begin
    base64s := Params.Values['_src'];
    base64s := StringReplace(base64s, 'data:image/png;base64,', '', [rfReplaceAll]);

    stream := TBytesStream.Create(DecodeBase64(base64s));
    try
      UnimImage1.LoadFromStream(stream);
    finally
      stream.Free;
    end;
  end;
end;

Best regards.

  • Upvote 3
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...