当我拍照时,我开始不断收到内存警告。我正在使用 Cordova 3.5 和带有这些设置的相机插件。
var _config;
var pictureSource;
var destinationType; // sets the format of returned value.
var encodingType; // enconding type 0=JPG 1=PNG
/**
* Initialize camera plugin.
* @param {object} config - settings.
*/
function initialize(config) {
alert("CAMERA is comming!!");
// Wait for Cordova to connect with the device
document.addEventListener('deviceready', onDeviceReady, false);
}
/**
* Cordova is ready to be used!
* @param {object} config - settings.
*/
function onDeviceReady() {
console.log("CAMERA is READY!!");
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
encodingType = navigator.camera.EncodingType;
capturePhoto();
}
/**
* Set camera plugin settings.
* @param {object} config - settings.
*/
function setConfig(config) {
_config = config;
}
/**
* Take picture using device camera and retrieve image as base64-encoded string.
*/
function capturePhoto() {
setConfig({ quality: 20, destinationType: destinationType.DATA_URL, encodingType: 0});
navigator.camera.getPicture(onPhotoDataSuccess, onFail, _config);
}
/**
* Photo is successfully retrieved.
* @callback getPicture~onPhotoDataSuccess
* @param {string} imageData - A base64-encoded image.
*/
function onPhotoDataSuccess(imageData) {
//Edit photo
}
我确保质量很低,但速度会变慢,直到崩溃。
感谢您的帮助!
最后,我通过修复照片尺寸解决了问题:
/**
* Take a picture and get the image as base64-encoded string.
*/
function capturePhoto() {
setConfig({ quality: 20, targetWidth: 600, targetHeight: 600, correctOrientation: true, destinationType: destinationType.DATA_URL, encodingType: 0});
navigator.camera.getPicture(onPhotoDataSuccess, onFail, _config);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)