Note that there are some explanatory texts on larger screens.

plurals
  1. POphoneGap camera and sencha touch view
    primarykey
    data
    text
    <p>I have to combine the phoneGap camera api with sencha touch.</p> <p>I have created a view <code>CameraView</code> and a controller <code>Camera</code>, but I don't know how to display the image captured by the camera on my view.</p> <pre><code> // JavaScript Document LoginForm.views.CameraView = Ext.extend(Ext.form.FormPanel, { id:'CameraView', title: "CameraView", html:'&lt;img height=200 width=200 id="myImage"/&gt;', initComponent: function() { Ext.apply(this, { bodyStyle:'background-color:#fff;padding: 10px', dockedItems: [{ dock:'bottom', xtype: "toolbar", id:"loginToolbar", title: "Login", items:[{ xtype:'button',cls:'x-backButton', ui:'back',text:'Back',cls:'x-button-back',handler:this.backButton,scope:this},{xtype:'spacer'}, { xtype:'button' ,cls:'x-cameraButtonBlack',ui:'normal',handler:this.onCameraClicked,scope:this } ] }], }); LoginForm.views.CameraView.superclass.initComponent.apply(this, arguments); }, onCameraClicked:function() { console.log("inside oncameracliked"); Ext.dispatch({ controller: 'Camera',action: 'capturePhoto'}); } }); Ext.reg('CameraView', LoginForm.views.CameraView); // JavaScript Document Ext.regController('Camera', { onBodyLoad:function () { document.addEventListener("deviceready",onDeviceReady,false); }, /* When this function is called, PhoneGap has been initialized and is ready to roll */ onDeviceReady: function () { phoneGapReady.innerHTML = "PhoneGap is Ready"; }, // Called when a photo is successfully retrieved // onPhotoDataSuccess:function(imageData) { // Uncomment to view the base64 encoded image data // console.log(imageData); // Get image handle // var myImage = document.Ext.getCmp('myImage'); // Unhide image elements // myImage.style.display = 'block'; // Show the captured photo // The inline CSS rules are used to resize the image // myImage.src = "data:image/jpeg;base64," + imageData; }, onPhotoURISuccess:function(imageURI) { // Uncomment to view the image file URI // console.log(imageURI); // Get image handle // var myImage = document.Ext.getCmp('myImage'); // Unhide image elements // myImage.style.display = 'block'; // Show the captured photo // The inline CSS rules are used to resize the image // myImage.src = imageURI; return(myImage.src); }, // A button will call this function // capturePhoto: function () { console.log("inside capture photo"); // Take picture using device camera and retrieve image as base64-encoded string try { console.log("inside try capture photo"); var pictureSource=navigator.camera.PictureSourceType; var destinationType=navigator.camera.DestinationType; navigator.camera.getPicture(this.onPhotoURISuccess, onFail, { quality: 50, destinationType: destinationType.FILE_URI }); } catch (err) { alert(err); } }, onFail: function (message) { alert('Failed: ' + message); }, backButton:function() { } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload