Created
November 1, 2012 11:56
-
-
Save benvium/3993233 to your computer and use it in GitHub Desktop.
AppFurnace: Capture Image from Camera and display on-screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //------------------------------------------------------------------------------------------------------------------------------ | |
| // 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