我使用以下内容
phonegap 3.6.0-0.21.18
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
我需要在phonegap中原生地剪裁图像到固定的宽度:650px和高度:250px . 我用来实现它的调用,如下所示 . 出于某种原因,当目的地类型为DATA_URL时,phonegap看不到需要使用相机启动裁剪工具 .
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
quality: 45,
allowEdit: true, <-- Forces the crop tool to appear if target sizes are different
targetWidth: 650,
targetHeight: 250,
destinationType: destinationType.DATA_URL, <--- Changed this to work
sourceType : Camera.PictureSourceType.CAMERA,
correctOrientation: true
});
但是当我用相机更改destinationType:destinationType.FILE_URI时,裁剪工具会在照片捕获后打开以进行裁剪 .
当我使用图库以及相同的参数进行尝试时,会出现裁剪工具
navigator.camera.getPicture(onPhotoURISuccess, onFail, {
quality: 45,
allowEdit: true, <-- Forces the crop tool to appear if target sizes are different
targetWidth: 650,
targetHeight: 250,
destinationType: destinationType.DATA_URL, <-- Didnt have to change for the crop tool to open
sourceType: pictureSource.SAVEDPHOTOALBUM,
mediaType : Camera.MediaType.PICTURE,
correctOrientation: true
});
我不明白相机和画廊电话之间的区别 . 这两个代码都使用目标类型作为destinationType.DATA_URL . 对于相机,裁剪工具不会打开,而对于图库它 . 这是android或phonegap中的一些错误吗?
1 回答
我认为这是javascript中的性能问题 . 我没有尝试本地裁剪图像,但我在iOS中有内存问题 . 我 grab 了base64字符串(DATA_URL),然后用javascript插件编辑它 . 我想你也需要base64图像 . 否则,FILE_URI会更好 .
看看John Wargo's answer,也许对你有帮助
这个cordova文档: