I need to copy an image file from canvas and save it to photos in iphone using phonegap. I use the js file https://github.com/devgeeks/Canvas2ImagePlugin/tree/master/www
<div class="win-n-lose-wrapper" id="workbox">
<div class="left-img"><img id="winner" src="img/img-1.jpg" alt=""></div>
<div class="right-img"><img id="looser" src="img/img-2.jpg" alt=""></div>
<canvas id="mycanvas" style="display:block;"></canvas>
</div>
<div class="next-wrapper">
<a class="btn_back" title="back" onclick="goBack();">Back</a>
<a class="btn" title="Next" onclick="share();">Copy</a>
</div>
</body>
and here is the code rest
function share()
{
var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
$('.save').attr({
'download': 'image.png', /// set filename
'href' : image /// set data-uri
});
}
I have not done any settings for this.
There is a good phonegap plugin for that.
https://github.com/devgeeks/Canvas2ImagePlugin
Hope this helps
For Saving image you can use:
function saveImage()
{
var canvas2ImagePlugin = window.plugins.canvas2ImagePlugin;
canvas2ImagePlugin.saveImageDataToLibrary(function(msg){console.log(msg);},function(err){console.log(err);},'yourCanvasId');
}
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.