javascript - 设置相机宽度和高度 phonegap 相机

标签 javascript android cordova phonegap-plugins

我目前正在创建一个使用 Phonegap (Cordova) camera plugin 的移动应用程序.它正确地捕获图像并将其显示在我想要的位置,但我似乎无法设置 targetWidth 和 targetHeight 选项,如所述。

targetWidth: Width in pixels to scale image. Must be used with targetHeight. Aspect ratio remains constant. (Number)

targetHeight: Height in pixels to scale image. Must be used with targetWidth. Aspect ratio remains constant. (Number)

据我了解,这将改变输出的图像宽度和高度。然而,他们似乎没有工作。

我在研究解决方案时发现的一个建议是使用可选参数 allowEdit。在此我可以让用户选择一个预设的方形图像。然而,这似乎也不起作用。

请参阅下面我的代码以供引用。

camera: function() {
    //Fire up the camera!
    navigator.camera.getPicture(onSuccess, onFail, {
        destinationType: Camera.DestinationType.DATA_URL,
        allowEdit: true,
        targetWidth: 512,
        targetHeight: 512
    });
},

两次尝试都没有达到我想要的效果;捕获图像的固定宽度和高度。

如何设置这张图片的宽度和高度?

最佳答案

试试这个我的 friend 。删除 allowEdit : true

camera: function() {
        navigator.camera.getPicture(onSuccess, onFail, {
            quality: 50,
            targetWidth: 512,
            targetHeight: 512,
            destinationType: navigator.camera.DestinationType. DATA_URL,
            saveToPhotoAlbum: true,
            correctOrientation: true
        });
    }

关于javascript - 设置相机宽度和高度 phonegap 相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27104686/

相关文章:

javascript - 在 Internet Explorer 中更改 onchange 处理程序中的 tabindex 时出现奇怪的行为

Javascript - 将 window.open() 与基本身份验证结合使用

java - 使用共享首选项检查新的一天

java - Gradle - 无法展开 zip cardview-v7-23.3.0.aar

ios - 谁能推荐解决IOS中 ionic 背景问题的解决方案

iphone - 在 Xcode 4 下构建 PhoneGap 时出现 undefined symbol 错误?

javascript - Fabric.js 背景仅在点击后出现

javascript - 错误 : Module "html" does not provide a view engine (Express)

java - 我不明白Android AutoCompleteTextView ArrayAdapter的构造函数

android - Phonegap构建:找不到与com.google.android.gms:play-services-gcm:12+相匹配的任何版本