简体   繁体   English

如何将二元数据字符串转换为钛制Appcelerator中的图像?

[英]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.

相关问题 在Appcelerator Titan中将Blob转换为位图图像 - Convert blob to bitmap image in Appcelerator titanium 如何将 Android Studio 项目转换为 Appcelerator Titanium 模块 - How to convert an Android Studio project to an Appcelerator Titanium Module Appcelerator Titanium图片和ico android - Appcelerator Titanium image and ico android 是否可以在加速器Titanium中像素化图像? - Is it possible to pixelate an image in appcelerator Titanium? 带图像的Appcelerator Titanium UI文本字段 - Appcelerator Titanium UI textfield with image 如何将二进制数据转换为图像? - how to convert binary data to image? 如何在Appcelerator Titanium项目中组织不同大小(设备)的图像文件 - How to organize image files of different sizes (devices) in a Appcelerator Titanium project 如何在应用重新启动/关闭时删除tempDirectory中的数据-Appcelerator Titanium - How to delete data in tempDirectory on app restart/shutdown - Appcelerator Titanium 在appcelerator / titanium mobile中,当在Webview中使用本地html时,如何从应用程序数据目录加载图像并引用该图像 - In appcelerator/titanium mobile, when using local html in a webview, how do I load an image from, and reference, the application data directory 如何在Android中将二进制字符串数据转换为字符串 - how to convert binary string data into String in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM