Titanium Community Questions & Answer Archive

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

How do i create imageview from Blob data stored in Sqlite Database?

Hi
I am trying make group functionality for my iphone application using whom user can able to make group by selecting desire iphone contacts.

For that i am making contact screen using titanium contacts API and getting all data successfully.

On selection of desire contacts i am storing all data in local database successfully.

But when i am trying create imageview using blob data which is store in local database in blob format. it gives me an error.

Expert comments needed to dig it out.

Thanks in advance.

— asked April 23rd 2010 by Chetan Detroja
0 Comments

8 Answers

  • Any luck with this? I have the same question.

    — answered May 1st 2010 by Ryan Huff
    permalink
    0 Comments
  • Sorry Ryan still not having luck to dig it out.. :)

    — answered May 3rd 2010 by Chetan Detroja
    permalink
    0 Comments
  • Were you able to find an answer to this? I have a lot of images store in a sqlite db as BLOB's that I need to have displayed in an image view as well.

    Thanks,
    Cory

    — answered June 19th 2010 by Cory Pratt
    permalink
    0 Comments
  • Were you able to find an answer to this? I have a lot of images store in a sqlite db as BLOB's that I need to have displayed in an image view as well.

    Thanks,
    Cory

    — answered June 19th 2010 by Cory Pratt
    permalink
    0 Comments
  • Same problem here :-(

    Any hint ??

    — answered September 11th 2010 by Pascal PLUCHON
    permalink
    0 Comments
  • (sorry for multipost)

    — answered September 11th 2010 by Pascal PLUCHON
    permalink
    0 Comments
  • Have you tried to base64 encode the image and put it in the db.
    http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Utils.base64encode-method.html

    Then when retrieving use the base64 string and embed to a webview.

    <img alt="Embedded Image" 
      src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />
    

    or just base64 decode http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Utils.base64decode-method.html

    — answered December 9th 2010 by Christian Sullivan
    permalink
    1 Comment
    • I have some images files in my local file system. I am trying to convert image file into base64 data using Titanium Utils. But after the conversion I am getting empty string… here is my sample code

      var f = Titanium.Filesystem.getFile(currIamge);
      var temp = f.read();
      var encodeData = Ti.Utils.base64encode(temp);
      alert("encodeData = "+encodeData);
      

      Here I am getting empty alert. How do I convert a file into base64 data? I am Using Titanium 1.7.5 in iOs platform

      — commented February 16th 2012 by Karthi Ponnusamy
  • i just posted some code for a module to do this conversion, I know a patch is coming from appcelerator, but the module might be useful to you now.

    Clearly Innovative Thoughts - Titanium Appcelerator Quickie: base64encode iOS Module

    — answered August 29th 2011 by Aaron Saunders
    permalink
    2 Comments
    • Thanks for the module Aaron but I can't get it to work. When I try to use it I only get returned a [object TiBlob]. I thought it would come back as a string. Here is how I do:

      var utils = require('utils');
      var f = Ti.Filesystem.getFile("test.png");
      Ti.API.info(utils.base64encode( f.read() ));
      

      — commented October 23rd 2011 by Knut Inge Grosland
    • I have uploaded the compiled module here http://bit.ly/u8azw8

      — commented November 8th 2011 by Aaron Saunders
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.