plus.gallery.pick(function(file) {
var path=plus.io.convertLocalFileSystemURL(file);
var image = new Image();
//image.setAttribute('crossOrigin', 'anonymous');加上此行代码,图片不能正常加载
image.src = path;
image.onload = function() {
var canvas=document.createElement("canvas");
var ctx=canvas.getContext("2d");
canvas.width=image.width;
canvas.height=image.height;
ctx.drawImage(image,0,0,image.width,image.height);
var base64 = canvas.toDataURL();
console.log(base64);
}
}
这段代码在android里面运行没有问题。
请问大佬,在ios下canvas.toDataURL()方法报错怎么办呢,给图片加跨域之后不报错但是图片加载不出来
7***@qq.com
- 发布:2018-12-21 11:59
- 更新:2019-10-06 17:48
- 阅读:1166
附近的拉力
请问解决了吗,遇到相同问题+1
2019-10-25 08:25
1***@qq.com
function GetBase64Code(path) { //path绝对路径
var bitmap = new plus.nativeObj.Bitmap("test"); //test标识谁便取
// 从本地加载Bitmap图片
console.log("path===="+path);
bitmap.load(path, function() {
var base4 = bitmap.toBase64Data();
console.log(base4);
console.log(base4.replace("data:image/jpeg;base64,",""));
2019-10-29 09:48