[英]how to convert binary data string into image in titanium appcelerator?
Hi I need to know how to decode a binary string into image format so that i would assign it to imageview.Here is the what i used to convert the image into binary. 嗨,我需要知道如何将二进制字符串解码为图像格式,以便将其分配给imageview。这是我用来将图像转换为二进制的内容。
function toBin(str){
var st,i,j,d;
var arr = [];
var len = str.length;
for (i = 1; i<=len; i++){
//reverse so its like a stack
d = str.charCodeAt(len-i);
for (j = 0; j < 8; j++) {
st = d%2 == '0' ? "class='zero'" : ""
arr.push(d%2);
d = Math.floor(d/2);
}
}
//reverse all bits again.
return arr.reverse().join("");
}
I need to know how to reverse back to image from binary string.Please help. 我需要知道如何从二进制字符串恢复到图像。请帮忙。
Ali 阿里
You can use to encode and decode in Titanium 您可以使用Titanium进行编码和解码
Ti.Utils.base64encode();
Ti.Utils.base64decode();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.