$cordovaCamera.getPicture与navigator.camera.getPicture


作者:LoveEmperor_王子様


多看API,多做实验;

本人最后还是用的$cordovaCamera.getPicture方法;界面显示图片更流畅,

$cordovaCamera.getPicture方法;

var options = {
  quality: 80,
  destinationType: Camera.DestinationType.DATA_URL,
  sourceType: Camera.PictureSourceType.CAMERA,
  encodingType: Camera.EncodingType.JPEG,
  targetWidth: 600,
  targetHeight: 600,
  popoverOptions: CameraPopoverOptions,
  saveToPhotoAlbum: false,
  correctOrientation:true
};

$cordovaCamera.getPicture(options).then(function(imageData) {

    $scope.img = "data:image/jpeg;base64," +  imageData;
    //alert(imageData);
    $scope.images_list.push($scope.img);
  $scope.allFile.push(imageData);

}, function(err) {
  // error
});

navigator.camera.getPicture方法;

function onDeviceReady() {        pictureSource=navigator.camera.PictureSourceType;      destinationType=navigator.camera.DestinationType;    }

   function onPhotoDataSuccess(imageData) {
     var smallImage = document.getElementById('smallImage');
     $scope.listShow = 1;
     //$scope.img = "data:image/jpeg;base64," +imageData;
     $scope.img = imageData;
     alert(imageData);
     $scope.images_list.push($scope.img);
     $scope.allFile.push(imageData);


       window.plugins.Base64.encodeFile(imageData, function (base64) {
         //$scope.myFileImage22   =(base64.slice(34));
         $scope.img = "data:image/jpeg;base64," +  (base64.slice(34));
         $scope.images_list.push($scope.img);
       
       });

     lrz(imageData)
       .then(function (rst) {
         $scope.myFileImage2 = (rst.base64.slice(23));
         $scope.allFile.push($scope.myFileImage2);
         //$scope.img = "data:image/jpeg;base64," +$scope.myFileImage2;
         //$scope.images_list.push($scope.img);
       })
       .catch(function (err){
       })
       .always(function () {
       });

   }

   function onPhotoURISuccess(imageURI) {
     var largeImage = document.getElementById('largeImage');
     largeImage.style.display = 'block';
     largeImage.src =imageURI;
   
   }

   var  self = this;

   $scope. capturePhotoEdit111 = function() {
     navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,       destinationType: destinationType.DATA_URL });    };
   $scope. capturePhotoEdit =function() {
     navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 40,    saveToPhotoAlbum: false ,     destinationType: destinationType.FILE_URI    });
     $scope.imageBorder = 1;
     $scope.clock = new Date();
     var updateClock = function() {
       $scope.clock = new Date();
     };
     //setInterval(function() {
     //  $scope.$apply(updateClock);
     //}, 1000);
     updateClock();
     var toTime = new Date($scope.clock.toString());
     $scope.dt2 = $filter("date")(toTime, "yyyyMMddHHmmss");
     $scope.cameraImageNum = 1;

   };
    $scope.getPhoto=function(source) {
     navigator.camera.getPicture(onPhotoURISuccess, onFail, { maximumImagesCount: 9, quality: 50,
       destinationType: destinationType.FILE_URI,
       sourceType:
         navigator.camera.PictureSourceType.PHOTOLIBRARY });
   };

   function onFail(message) {      alert('Failed because: ' + message);    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王子様~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值