简体   繁体   中英

How to Save HTML5 canvas image on android SD card in Android Phonegap?

Hi I have one edited canvas image.Now I want to save it on android SD card using JavaScript. I have tried to save, but it is converting as base64encode format.I need simple image file like test.jpeg, test.PNG and etc.I am not able to get decode.

The image base64 format is like 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...'.

How to get the image file and save it to android SD card.

Please help me.Thanks in advance.

You can do a:

var context = myCanvas.getContext('2d');

var myPNG = context.toDataURL('image/png');

Now you have the canvas in .png format, which you should be able to save. Hope that helped!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM