我需要从画布复制图像文件并使用phonegap将其保存到iphone中的照片中。我使用js文件 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>
这是代码休息
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
});
}
我没有为此做过任何设置。
答案 0 :(得分:0)
答案 1 :(得分:0)
对于保存图像,您可以使用:
function saveImage()
{
var canvas2ImagePlugin = window.plugins.canvas2ImagePlugin;
canvas2ImagePlugin.saveImageDataToLibrary(function(msg){console.log(msg);},function(err){console.log(err);},'yourCanvasId');
}