[英]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.