【问题标题】:how to display full image taken from camera in ionic?如何在离子中显示从相机拍摄的完整图像?
【发布时间】:2017-04-17 17:42:33
【问题描述】:

我正在尝试使用宽度为 600、高度为 800 像素的 img 标签显示相机拍摄的整个图像。但是由于某种原因,在拍照后它会在显示后被剪切。如何将照片放入 600x800 像素的 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);
}

}])

【问题讨论】:

    标签: angularjs ionic-framework


    【解决方案1】:

    我将其添加到 html 中的标记中:style='height: 100%;宽度:100%;对象拟合:包含'

    【讨论】:

      猜你喜欢
      • 2018-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-18
      • 2012-10-11
      • 1970-01-01
      相关资源
      最近更新 更多