如何在cordova相机中选择画廊和相机

时间:2015-08-12 10:07:51

标签: cordova camera

我正在使用cordova-camera插件拍照。但有时用户想要在图库和相机之间进行选择。我该如何提供该选项 我有以下代码

navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
        destinationType: Camera.DestinationType.DATA_URL
      });

      function onSuccess(imageData) {
        var finalimage = "data:image/jpeg;base64," + imageData;
    }); 

我对更改destinationType

持怀疑态度

2 个答案:

答案 0 :(得分:2)

默认情况下,sourceType是相机。对于图库sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY

您可以添加的目标类型 destinationType: navigator.camera.DestinationType.DATA_URL  OR

navigator.camera.DestinationType. FILE_URI

答案 1 :(得分:0)

声明选项有两种可能性:

var options = { quality: 100,
                destinationType: Camera.DestinationType.DATA_URL,
                sourceType: Camera.PictureSourceType.CAMERA,
                encodingType: Camera.EncodingType.JPEG,
                correctOrientation: true
              };

OR

navigator.camera.getPicture(onSuccess, onFail, options);

在声明选项之后,你可以像这样调用getPicuture函数:

{{1}}