Question

I have a list of images encoded as ByteArrays from an API to be displayed in a TableView

Here is one of the ByteArrays

i'm not managing to display an image with it, nor saving a file or making a buffer or a stream buffer, those are some examples

var blobStream = Ti.Stream.createStream({ source: array, mode: Ti.Stream.MODE_READ });

or

var buff = Ti.createBuffer({value:array, length:array.length, type:Ti.Codec.CHARSET_UTF8});

and giving the array either to

Titanium.Utils.base64decode( array ); 
Titanium.Utils.base64encode( array ); 

crashes badly with "wrong type passed to function"

How can I make a blob out of a ByteArray and set it to an Imageview?

Was it helpful?

Solution

You can use this snippet to convert byte array in base64 string.

Decode the string with var imageBlob = Ti.Utils.base64decode(string);

and than set it in var image = Ti.UI.createImageView({ image:imageBlob });

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top