Skip to content

Instantly share code, notes, and snippets.

@benvium
Created November 1, 2012 11:56
Show Gist options
  • Select an option

  • Save benvium/3993233 to your computer and use it in GitHub Desktop.

Select an option

Save benvium/3993233 to your computer and use it in GitHub Desktop.
AppFurnace: Capture Image from Camera and display on-screen.
//------------------------------------------------------------------------------------------------------------------------------
// Call this function on a button press. The image will be displayed on an Image widget with code name 'ui.photo'
//------------------------------------------------------------------------------------------------------------------------------
function takePhoto() {
navigator.camera.getPicture(photoSuccess, photoFail, { quality: 15, destinationType : 0 });
}
// Called when taking a photo works, resizes it and puts it up on the screen for the user.
// Then grabs that as a string and stores it for later uploading.
function photoSuccess(imageString) {
if (imageString && imageString.length > 100) {
ui.photo.backgroundImage( "data:image/jpeg;base64," + imageString );
} else {
popup("There was a problem taking the picture, please try again.", "Picture Failed");
}
}
function photoFail(message) {
popup('Failed to take photo because: ' + message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment