var Img = new Image();
Img.src = sd_path;
console.log("1=================================");
Img.onload() = function() {
console.log("2=================================");
var myCanvas = document.createElement("canvas");
myCanvas.width = Img.width;
myCanvas.height = Img.height;
var ctx = myCanvas.getContext("2d");
ctx.drawImage(Img, 0, 0);
ctx.font = "80px microsoft yahei";
ctx.fillStyle = "rgba(255,0,0,1)";
ctx.fillText("拍照时间:" + getNowFormatDate(), 0, Img.height - 100, myCanvas.width - 10);
console.log("3=================================");
data = myCanvas.toDataURL();
//TODO bitmap 修改图片 start
var bitmap = new plus.nativeObj.Bitmap();
console.log("4=================================");
bitmap.loadBase64Data(data, function() {
console.log("加载图片成功");
}, function() {
console.log("加载图片失败");
});
bitmap.save(sd_path, {
overwrite: true,
format: "jpg",
}, function(i) {
var result = JSON.stringify(i);
var data = JSON.parse(result);
var target = data.target;
console.log('保存图片成功:' + result);
//start
var imageDiv = document.createElement("div");
imageDiv.className = "media-item image-item mui-col-"
imageDiv.innerHTML = '' +
'<img class="file mui-action-preview" data-preview-src="' + target + '" data-preview-group="1" src="' + target + '" addTime="' + (new Date()).getTime() + '" />' +
'<span class="mui-icon mui-icon-closeempty"></span>';
imageList.appendChild(imageDiv);
console.log("加入图片列表的地址:" + target);
//在这里获取到图片的路径
photoPath = target;
bitmap.clear();
//end
}, function(e) {
console.log('保存图片失败:' + JSON.stringify(e));
});
//TODO bitmap 修改图片 end
}*/
3 个回复
l***@163.com (作者)
只打印了1=====;把Bitmap.loadBase64Data注释,程序是正常的。有没有什么办法在bitmap.loadBase64Data处理这块。
arjen - 80
遇到同样的问题了,解决了吗?
sssuxin
遇到了相同的问题,请问楼主解决了嘛