Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

View BLOB in an Image View

$
0
0

Hello folks,

I have an iOS application that receives images encoded in Base64 strings from a Web API, and I want to view these images in ImageViews, my problem lies in not being able to view them.

The workflow is as follows: 1: Get Base64 String. 2: Convert it to BLOB object. 3. Assign the BLOB object to the "image" field of the ImageView.

Code snippet:

var imageBase64String = "{valid base64 string}";
 
var imageBlob = Ti.Utils.base64decode(imageBase64String);
 
$.UserImageView.image = imageBlob;
$.UserImageView.show();
The above code snippet matches the exact steps in my code. What happens is that when I view that window, the ImageView shows up blank - white space! No exceptions or errors occur! I have tried to decode the base64 string using different tools and it worked fine, but something is going wrong in Titanium that I'm not aware of.

I have also tried to clean up the Base64 string as follows, but the problem still persists!

var imageBlob = Ti.Utils.base64decode(imageBase64String.trim().replace(/(\r\n|\n|\r)/gm, ""));

Your help is much appreciated.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>