Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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?

— asked October 7th 2010 by Karthikeyan Chandran
  • android
  • encodine
  • iphone
0 Comments

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);
    }

    });

    — answered November 26th 2012 by Anmol Gupta
    permalink
    0 Comments
  • 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

    — answered October 7th 2010 by Roger Chapman
    permalink
    1 Comment
    • I need to upload the image in MySql database.

      — commented October 8th 2010 by Karthikeyan Chandran
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.