将来自Web服务的字节数组转换为UIImage iPhone [英] Converting byte array coming from Web service to UIImage iPhone
本文介绍了将来自Web服务的字节数组转换为UIImage iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是这项技术的新手。
我搜索了很多,但无法找到相关的。
在我的应用程序中,我从Web服务接收字节数组,我从Web服务收到的字节数组是
I am new to this technology. I searched a lot but cant find any relevant. In my application,I am receiving byte array from web service, my byte array which I receive from web service is
[ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,195,0,0,1,195,8,2,0, 0,0,215,2 ...]
[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,195,0,0,1,195,8,2,0,0,0,215,2... ]
我希望将此字节数组转换为 UIImage 用于在 UIImageView 中显示它。
and I want to convert this byte array into UIImage for showing it in UIImageView.
推荐答案
使用下面的UIImage构造函数。
Use below constructor for UIImage.
+ (UIImage *)imageWithData:(NSData *)data;
NSData *data = [NSData dataWithBytes:YOUR_BYTE_ARRAY length:ARRAY_LENGTH];
UIImage *img = [UIImage imageWithData:data];
UIImageView *imgView = [[UIImageView alloc]initWithImage:img];
这篇关于将来自Web服务的字节数组转换为UIImage iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文