Created
May 15, 2012 19:44
-
-
Save timkim/2704508 to your computer and use it in GitHub Desktop.
Short example of how to get photo from PhoneGap Camera to canvas
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
// Note: have not tested this - but I think it should work! | |
function cameraWin(picture){ | |
var theCanvas = document.getElementById('theCanvas'); | |
var ctx = theCanvas.getContext('2d'); | |
var theImage = new Image(); | |
theImage.src = "data:image/jpeg;base64,"+picture; | |
ctx.drawImage(theImage, 0, 0); | |
} | |
function cameraFail(){ | |
alert('camera dead'); | |
} | |
function takePicture(){ | |
navigator.camera.getPicture(cameraWin, cameraFail, {quality: 50, destinationType: Camera.DestinationType.DATA_URL}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It does not work for me. Only other thing I need is the canvas, right?
It does not display the image on the canvas :/