Since the camera is event driven, you cannot just bind events and hope for the best ... In the callback of the successcode that uses the image, you must call , then the code to load the image.
EDIT
Here I use the URI returned when the image was successfully drawn. But it should be pretty simple.
function takePicture() {
loadPhotoIntake();
navigator.camera.getPicture(
setPicture,
function(e) {
console.log("Error getting picture: " + e);
document.getElementById('camera_status').innerHTML = "Error getting picture.";
},
{ quality: 70, destinationType: navigator.camera.DestinationType.FILE_URI});
};
function setPicture(uri) {
var c=document.getElementById('camera_image');
var ctx = c.getContext('2d');
var img = new Image();
var canvasCopy = document.createElement("canvas");
var copyContext = canvasCopy.getContext("2d");
var maxWidth, maxHeight;
img.onload = function(){
.....
ctx.drawImage(canvasCopy, 0, 0, camera_image.width, camera_image.height);
};
img.src = uri;
}
source
share