我已经开发了画布图像来存储画廊。我已经添加了插件从
**cordova plugin add https://github.com/devgeeks/Canvas2ImagePlugin.git**
字符串
我已经把签名写在设备里了,但是无法保存在图库里。
以下代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/modernizr.custom.34982.js"></script>
<script type="text/javascript" src="js/signatureCapture.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.2.css" />
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<script type="text/javascript">
var sigCapture;
$(document).ready(function(e)
{
sigCapture = new SignatureCapture( "signature" );
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady()
{
window.canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
console.log("Save =========>"+msg);
},
function(err){
console.log("Error =====>"+err);
},
document.getElementById('signature')
);
}
$("#submit").click( onSubmitClick );
$("#cancel").click( onCancelClick );
});
function onSubmitClick(event ) { }
function onCancelClick( event ) {
sigCapture.clear();
}
</script>
</head>
<body>
<h2>SIGNATURE</h2>
<div id="canvasContainer" >
<canvas id="signature" />
</div>
<button data-role="button" id="submit" data-theme="b">Save</button>
<button data-role="button" id="cancel" data-theme="b">Cancel</button>
</body>
</html>
型
错误控制台:
无法在file:/android_asset/www/index.html:55解码图像
请有人可以帮助我如何保存画布上的文字在图片库。
1条答案
按热度按时间insrf1ej1#
您可以使用toDataURL方法将画布转换为URL,然后您可以使用此URL下载画布,类似于:
字符串