mardi 10 février 2015

How to convert camera uri to blob object in Phonegap?

In my application, camera image save and retrieve from SQLite. I have camera uri from phonegap api but i want to convert camera uri to blob object and base64 string. I found some of the solution from online but i can't solve my problem. This is convert Base 64 to Blob object. I already tried that link. I can't convert to blob object.



using phonegap-1.4.1.js


Index.js



function onPhotoFileSuccess(imageData){
console.log(JSON.stringify(imageData));

var smallImage = document.getElementById('imageview'+imageviewcount);
smallImage.style.display = 'block';
smallImage.src = imageData;

// "imageData" parameter is image uri
// I don't know how to convert image uri to blob object

// save to SQLite
var db = window.sqlitePlugin.openDatabase(Mydb , ver, "", size);

db.transaction(function(tx) {tx.executeSql("Insert Into "+ DOPhotoTable +"( RefTranNo,Photo) values(?,?);",["007", blobobject]);});
}

function takeCameraImage(){
navigator.camera.getPicture(onPhotoFileSuccess, onFail, { quality: 30, destinationType: Camera.DestinationType.FILE_URI });
}


In onPhotoFileSucces function, i want to convert image uri to blob object.


Aucun commentaire:

Enregistrer un commentaire