NJS要保证load的图片base64数据正确
另外5+Runtime也封装了Bitmap API
请参考 http://www.html5plus.org/doc/zh_cn/nativeobj.html#plus.nativeObj.Bitmap
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>NativeObj Example</title>
<script type="text/javascript">
var wc=null,bitmap=null;
// H5 plus事件处理
function plusReady(){
wc = plus.webview.currentWebview();
bitmap = new plus.nativeObj.Bitmap("test");
// 加载Base64编码格式图片到Bitmap对象
bitmap.loadBase64Data( "iVBORw0KGgoAAAANSUhEUgAAABgAAAAsCAYAAAB/nHhDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNC8yOC8xMqLz6JEAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAABJ0lEQVRYhe3Wv6rCMBQG8C/VN1AEd3HSzuYO3jr4knkY0UE62xTBcp9A8A0uHhc72CZp/lQQyZmT7xfSJKeMiPDOSt6aHoEIRKAbkLKioqiCrroWkLKi+51ARAhBlEAdXlcI0gLK8u8lPBRpAYvFjCUJUw72QZRbtFzOe0O0H7kvxHhM83yfhiJdF+2c5/utCTmdLnS93rQQs2mZQogN59lOdbrqmk7HmExGrZVYAU9kzXl2cEWsgSfys1r9Hk1TmogTAABFcTFOaQJOr6mUlVO4E9B8n2zCrQHfcAAYmoKFEAPOs39dOGMMaTpXX5J6jGlTTSu3CQcsGk5IuBboK1wJ6BqOT7gS0DUcn3AlALR7gW84YHGKiOAd3gn0UV/+6xiBCHwG8AByzMrOPKV7sAAAAABJRU5ErkJggg==", function(){
console.log("加载Base64图片数据成功");
}, function(){
console.log('加载Base64图片数据失败:'+JSON.stringify(e));
} );
}
if(window.plus){
plusReady();
}else{
document.addEventListener("plusready",plusReady,false);
}
// 保存图片
function saveBitmap(){
bitmap.save( "_doc/a.jpg"
,{}
,function(i){
console.log('保存图片成功:'+JSON.stringify(i));
}
,function(e){
console.log('保存图片失败:'+JSON.stringify(e));
});
}
</script>
</head>
<body>
保存图片<br/>
<button onclick="saveBitmap()">Save</button>
</body>
</html>
5 个回复
最佳回复
半杯可乐 - 努力奋斗中。
NJS要保证load的图片base64数据正确
另外5+Runtime也封装了Bitmap API
请参考 http://www.html5plus.org/doc/zh_cn/nativeobj.html#plus.nativeObj.Bitmap
Johnson
咱俩一样 我现在也是undefined 已疯 请问如何解决的
DCloud_IOS_XTY
http://ask.dcloud.net.cn/question/6190
2016-07-22 18:46
1***@qq.com
mark
1***@qq.com
mark
s***@163.COM
mark