[英]Save Canvas image to the device/gallery on android
因此,我现在尝试了几天,以从我的应用程序的Canvas中获取图像并将其保存到设备中……我尝试了一些(无结果)插件,例如:Save2Canvas,Base64 To Gallery,Canvas2ImagePlugin和Cordova base64ToGallery插件...
我正在使用:Cordova 7.0.1 Ionic 1.x
现在,我Js的一部分。 保存的功能是这样的
var image = canvas
.toDataURL("image/png");
window.location.href=image;
Wich kinda可以通过浏览器在ionic 1.x上运行,但不能在设备上运行...
使用canvas2ImagePlugin (您提到的)尝试此操作。 这对我来说很有效,可以将我的画布内容保存到图库中。
<canvas id="myCanvas" width="165px" height="145px" ></canvas>
<script>
//get the canvas element
var canvas = document.querySelector('canvas');
//save to Gallery
window.canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
console.log(msg);
},
function(err){
console.log(err);
},
document.getElementById('myCanvas')
);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.