简体   繁体   English

Phonegap在图像捕获期间返回当前方向

[英]Phonegap return current orientation during image capture

I can only find information in their docs about the Accelerometer for returning device orientation. 我只能在他们的文档中找到有关返回设备方向的Accelerometer的信息。 Is there anyway phonegap can return what way the device was being held when a picture was taken? 无论如何,手机屏幕可以返回拍摄照片时设备的持有方式吗? To use the camera, I do this: 要使用相机,我这样做:

function capturePhoto() {
    // Take picture using device camera and retrieve image as base64-encoded string
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
        destinationType: destinationType.DATA_URL });
}

When it returns successful, it does this. 当它返回成功时,它会执行此操作。

 function onPhotoDataSuccess(imageData) {
        var baseImg = imageData;
        $('#uploadPreUpImgSwapHtml').html('<img src="data:image/jpeg;base64,'+ baseImg +'" style="max-width:100%; width:auto; max-height:300px; height:auto;" / >');
        $('#uploadPreBaseDataSwapHtml').html('<input type="hidden" id="chosenPictureData" value="'+ baseImg +'" />');
        $('#uploadPictureBtnHideHtml').fadeIn();

    }

Is there a callback to the success that returns what way the device was being held while the picture was taken so I can send it to my upload file and rotate the picture correctly? 是否有回调成功,返回设备被拍摄时的方式,以便我可以将其发送到我的上传文件并正确旋转图片?

To make your life easier you can just call: 为了让您的生活更轻松,您可以致电:

navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
    destinationType: destinationType.FILE_URI, 
    correctOrientation: true });

then you'll get a file that is rotated properly. 然后你会得到一个正确旋转的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM