![](/img/trans.png)
[英]trouble with canvas.toDataURL and drawimage on Android phone
[英]canvas.toDataURL not working on Android >4 devices (but on Android 2)
我正在使用Cordova / Ionic构建应用程序。 用户可以操纵他的gallery-fotos,然后显示在应用程序上。
我现在面临的问题是,在操作之后,Android> 4设备(Android 4,Android 5,Android 6等)上的图像不会显示。 只有一个“图像未找到” - 图像可见。 但一切都在Android 2.x设备上按预期工作。
这些版本之间是否有任何重大变化?
使用此插件完成操作。
我的代码如下所示( index.html )
<img src="{{!!image.img11 ? image.img11.src : 'img/layout/placeholder.png'}}" ng-cloak>
App.js
navigator.camera.getPicture(onSuccess, onFail,
{
quality: 30,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
targetWidth: imagePickerWidth,
targetHeight: imagePickerHeight,
encodingType: Camera.EncodingType.PNG,
allowEdit: false
});
function onSuccess(imageURI) {
self.crop(resolve, reject, scope, imageURI, type, width, height, tabs);
/* JR-CROP MANIPULATION */
scope.image.img11 = new Image();
scope.image.img11.src = canvas.toDataURL("image/png");
}
好吧,似乎在Android大于5(5,6,7)的情况下, index.html
header
需要security-policy
。
只需添加以下内容:
<head>
<meta http-equiv="Content-Security-Policy" content="img-src 'self' data:;">
...
</head>
这允许显示base64
编码图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.