Android 如何将摄像头中的图像保存到手机上,并使用ionicframework检索图像以显示在div上
这就是我如何拍摄我的图像Android 如何将摄像头中的图像保存到手机上,并使用ionicframework检索图像以显示在div上,android,cordova,ionic-framework,Android,Cordova,Ionic Framework,这就是我如何拍摄我的图像 $scope.takePhoto = function () { var camera_options = { // CONFIG 1. CAMERA SETTINGS quality: 80, destinationType: Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.CAMERA,
$scope.takePhoto = function () {
var camera_options = { // CONFIG 1. CAMERA SETTINGS
quality: 80,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 100,
targetHeight: 100,
correctOrientation: true,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(camera_options).then(function (imageData) {
//$scope.imgSrc = "data:image/jpeg;base64," + imageData;
$scope.imgSrc = imageData;
$scope.imgData = imageData;
$scope.$apply();
}, function (err) {
$cordovaDialogs.alert('Picture Not Taken', 'Error', 'OK');
});
}
之后,我尝试用这种方式将图像保存到android的内存中
$cordovaFile.writeFile(cordova.file.externalRootDirectory, 'app/profile/' + data.id + '.jpeg', $scope.imgSrc, {'append': false}).then(function (result) {
$cordovaDialogs.alert('Image saved', 'Success', 'OK');
}, function (err) {
// An error occured. Show a message to the user
$cordovaDialogs.alert('Image not saved', 'Error', 'OK');
});
保存的图像无法仅打开其非常小的9字节。我做错了什么