any one help me to encode and decode image data in titanium?
I need to upload the image to database , as well as download the image from database to display , any method or API is available to do this task?
2 Answers
-
var win = Titanium.UI.createWindow({
backgroundColor:'white',
});var imgv=Titanium.UI.createImageView({
image:"mysic_player_defaultartwork.png",height:100,
width:100,
top:10,
});win.add(imgv);
var imgview=Titanium.UI.createImageView({
image:'KS_nav_ui.png',
height:100,
width:100,
top:150,
});win.add(imgview);
var btn=Titanium.UI.createButton({
bottom:100,
width:100,
height:50,
title:'click'
});
win.add(btn);
win.open();btn.addEventListener('click',function(e){
var str= Titanium.Utils.base64encode(imgv.toBlob());
try{
var blob = Titanium.Utils.base64decode(str);
imgview.image = blob;
}
catch(e){
alert("exception : " + e);
}});
-
Are you talking about a database on a server or a local database on the app?
If you are talking about the local SQLite database have a look at page 19 of the Database Reference Guide with explains all about Blob data. http://assets.appcelerator.com.s3.amazonaws.com/docs/API_DatabaseClass.pdf