使用离子框架如何捕获图像并将其保存到图库?
我尝试了几个选项,但它与Marshmallow版本的Android不兼容。
答案 0 :(得分:1)
添加cordova-plugin-camera插件
命令:离子插件添加cordova-plugin-camera
HTML
<span class="button" ng-click = captureImage();> Capture </span>
价: http://ngcordova.com/docs/plugins/camera/
JS
.controller('cameraCtrl', function($scope,$cordovaCamera) {
$scope.captureImage = function() {
var options = {
quality: 100,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
}, function(err) {
console.log("An error Occured");
});
}
});
答案 1 :(得分:0)
cordova-plugin-camera (For capturing Image)
cordova-plugin-file-transfer (For uploading)
cordova-plugin-file (For accessing device’s files and directories )
根据您的要求使用这些插件。 http://ngcordova.com/docs/plugins/camera/
之后如果你面对的是没有出现问题的imgae,请使用此
cordova plugin add cordova-plugin-refresh-gallery