如何在离子中显示从相机拍摄的完整图像?

时间:2017-02-20 03:32:51

标签: angularjs ionic-framework

我尝试使用宽度为600且高度为800像素的img标签显示相机拍摄的整个图像。但由于某些原因,拍照后它会被切断一次。我如何在600x800pixel img元素内拟合照片?

这是我对controllers.js的代码:

.controller('idValidationCtrl', ['$scope', '$stateParams', '$cordovaCamera','$cordovaFile', function ($scope, $stateParams,$cordovaCamera,$cordovaFile) {
 $scope.addImage = function()
{
   navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50 });
}

//Callback function when the picture has been successfully taken
function onPhotoDataSuccess(imageData) {                
    // Get image handle
    var smallImage = document.getElementById('smallImage');

    // Unhide image elements
    smallImage.style.display = 'block';
    smallImage.src = imageData;
}

//Callback function when the picture has not been successfully taken
function onFail(message) {
    alert('Failed to load picture because: ' + message);
}

}])

1 个答案:

答案 0 :(得分:1)

我将此添加到html中的标记:style =' height:100%;宽度:100%; object-fit:包含'