gpt4 book ai didi

ios - 在 Cordova 中使用相机后收到内存警告 iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:03:01 28 4
gpt4 key购买 nike

当我拍照时,我开始不断收到内存警告。我正在使用 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);
}

关于ios - 在 Cordova 中使用相机后收到内存警告 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26808751/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com