0

我正在使用官方网站上的以下示例- 因此将 sourceType 设置为 CAMERA 而不是 PHOTOLIBRARY。

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

    $cordovaCamera.getPicture(options).then(function(imageData) {
      var image = document.getElementById('myImage');
      image.src = "data:image/jpeg;base64," + imageData;
    }, function(err) {
      // error
    });

并且正在使用 phonegap 构建测试我的应用程序,因此在我的 config.xml 中合并了以下插件:

但是,当我启动上面的代码时,它会在我的应用程序中打开我的手机相册 - 从而迫使我选择图像而不是拍照。到底是怎么回事?

4

1 回答 1

0

对于相机,你可以试试这个

var options = {
    quality: 50,
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: Camera.PictureSourceType.CAMERA,
    allowEdit: true,
    encodingType: Camera.EncodingType.JPEG,
    targetWidth: 100,
    targetHeight: 100,
    popoverOptions: CameraPopoverOptions,
    saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageURI) {
    var image = document.getElementById('myImage');
    image.src = imageURI;
}, function(err) {
    // error
});
于 2015-03-02T15:20:36.370 回答