Using the Device Camera with PhoneGap


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $( '#camera' ).bind( 'touchstart', function() {
  2. $( this ).attr( 'src', 'assets/camera.down.png' );
  3.  
  4. navigator.camera.getPicture( function( data ) {
  5. $( '#photo' )
  6. .attr( 'src', 'data:image/jpeg;base64,' + data )
  7. .css( 'visibility', 'visible' );
  8.  
  9. $( '#camera' ).attr( 'src', 'assets/camera.up.png' );
  10. }, function( error ) {
  11. console.log( 'Error' );
  12. }, {
  13. destinationType: Camera.DestinationType.DATA_URL,
  14. sourceType: Camera.PictureSourceType.CAMERA,
  15. allowEdit: false,
  16. targetWidth: 260,
  17. targetHeight: 435
  18. } );
  19. } );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.