2016-10-19 11 views
0

ピクチャから撮影した写真は、camera cordova pluginを使用して切り抜きオプションに表示されません。しかし、トリミングオプションはギャラリーから「画像」を選択するか、カメラから写真を撮ると表示されます。写真から撮影した写真は、アンドロイドのコードバカメラプラグインで切り抜いて表示されません。

プラグイン

コルドバ - プラグインカメラ2.1.1

コード

var options = { 
      quality: 75, 
      destinationType: Camera.DestinationType.DATA_URL, 
      sourceType: Camera.PictureSourceType.PHOTOLIBRARY, 
      allowEdit: true, 
      encodingType: Camera.EncodingType.JPEG, 
      targetWidth: 300, 
      targetHeight: 300, 
      popoverOptions: CameraPopoverOptions, 
      saveToPhotoAlbum: false 
     }; 
     $cordovaCamera.getPicture(options).then(function(imageData) { 
     console.log('succes') 
     }, function(err) { 
     console.log('succes') 
     }); 

私は本当にこの問題を解決取得するいくつかの助けを必要とすることができます。

+0

バージョンを使用している

angular.module('starter', ['ionic','ngCordova']) 

camera.html

<ion-content> <div class="list"> <div class="item item-thumbnail-right item-icon-right" ng-click="toCamera()"> <img id="myImage" style="margin-right:50px;"> <h2 class="positive">Camera</h2> <i class="icon ion-ios-arrow-right balanced"></i> </div> </div> </ion-content> 

controllers.js? –

+0

cordova-plugin-camera 2.1.1 –

答えて

2

ngCordove - Cameraを参照できます。

依存性注入が必要 「ngCordova」を追加すると、このようになります。

app.jsコルドバの

app.controller('CameraCtrl', function ($scope, $cordovaCamera) { 

$scope.toCamera = function() { 
    var hideSheet = $ionicActionSheet.show({ 
     buttons: [ 
      { text: 'Take a picture' }, 
      { text: 'Select a picture' } 
     ], 
     cancelText: 'Cancel', 
     cancel: function() { 
     }, 
     buttonClicked: function (index) { 
      console.log(index); 
      if (index == '0') { 
       document.addEventListener("deviceready", function() { 
        //take a picture 
        var options = { 
         quality: 100, 
         destinationType: Camera.DestinationType.DATA_URL, 
         sourceType: Camera.PictureSourceType.CAMERA, 
         allowEdit: true, 
         encodingType: Camera.EncodingType.JPEG, 
         targetWidth: 1280, 
         targetHeight: 720, 
         popoverOptions: CameraPopoverOptions, 
         saveToPhotoAlbum: true, 
         correctOrientation: true 
        }; 
        $cordovaCamera.getPicture(options).then(function (imageData) { 
         var image = document.getElementById('myImage'); 
         image.src = "data:image/jpeg;base64," + imageData; 
        }, function (err) { 
         // error 
        }); 
       }, false); 

      } else if (index == '1') { 
       document.addEventListener("deviceready", function() { 
        //Select a picture 
        var options = { 
         destinationType: Camera.DestinationType.FILE_URI, 
         sourceType: 2,  //set 0 or 2,is system picture 
         quality: 100, 
         allowEdit: true, 
         targetWidth: 1280, 
         targetHeight: 720 
        }; 

        $cordovaCamera.getPicture(options).then(function (imageURI) { 
         var image = document.getElementById('myImage'); 
         image.src = imageURI; 
        }, function (err) { 
         // error 
        }); 

        //$cordovaCamera.cleanup().then(); // only for FILE_URI 

       }, false); 
      } 
      return true; 
     } 
    }) 
}}); 
+0

ギャラリーから画像を選択すると切り抜きオプションが表示されます。または、画像内の画像ではありません。 –

+0

allowEdit:true – Chaoyenpo

+0

私は試しました。しかし使用しないでください –

関連する問題