Best way to save cavas image

54 views
Skip to first unread message

Leandro P

unread,
Jul 22, 2016, 2:40:04 PM7/22/16
to DroidScript
Hi,

In my app, i create an image on canvas in webview context.

What would be de best way to save it to a file?

thanks!

Steve Garman

unread,
Jul 22, 2016, 6:17:39 PM7/22/16
to DroidScript
I can't think of any way to do it.

I have an idea in the back of my mind there may be a way using base64 but I can't bring it to mind.

BareK

unread,
Jul 23, 2016, 12:32:50 PM7/23/16
to DroidScript

Leandro P

unread,
Jul 25, 2016, 9:15:09 AM7/25/16
to DroidScript
Hi all,

In first place thanks you your answers Steve and BareK.


Well, I tried everything (Anchor tag with download attr; app.WriteFile withy "base64" on encoding param; and anything else) and didn't work.

So, i made a "workaround" that worked and here it goes, in case someone needs that too:


1° - I create a new webView and add it to the main app layout;

2° - The canas has to cover 100% of the height and width, of the new webView;

3° - Draw everything i need on the canvas;

4° - I save the image using: web.Capture("/sdcard/MyDrawing.png");

5° - Close the webView;


PS. On attach goes the full app (Just an example).

Best regards to all.
Drawing.spk
Reply all
Reply to author
Forward
0 new messages