如何将数据转换为图像?
我学习CFNetwork,socket,我快完成了。但是,我想使用 UIImageView,这样 从 URL 接收数据,然后转换为 UIImage ,然后添加 UIImageView
但我认为它在将数据转换为图像方面存在问题,
我在下面的代码中使用...
void CFSockCallBack(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info){
if (callbackType == kCFSocketDataCallBack) {
UInt8 *d = (UInt8 *)CFDataGetBytePtr((CFDataRef)data);
int len = CFDataGetLength((CFDataRef) data);
NSData *nsdata = [NSData dataWithBytes:d length:len];
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 460.0)];
UIImage *receiveImage = [UIImage imageWithData:nsdata];
imageView 是实例 decared static 。
你明白我的编码吗?那么TT 请帮助我!
i learning CFNetwork , socket, i almost completed. But, I want to use UIImageView, so that
receive data from URL, then transform to UIImage , then add UIImageView
but i think that it has a problem about transform data to image
i use below code...
void CFSockCallBack(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info){
if (callbackType == kCFSocketDataCallBack) {
UInt8 *d = (UInt8 *)CFDataGetBytePtr((CFDataRef)data);
int len = CFDataGetLength((CFDataRef) data);
NSData *nsdata = [NSData dataWithBytes:d length:len];
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 460.0)];
UIImage *receiveImage = [UIImage imageWithData:nsdata];
imageView is instance delcared static .
do you understand my coding? T.T then
Plz help me!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将 imageView 的 image 属性设置为 receiveImage ?或者这只是意外地被排除在代码片段之外?您是否还收到某种错误消息或只有空白的 UIImageView 空间?
Are you setting the imageView's image property to the receiveImage? Or that was only accidentally left out of the code snippet? Also are you getting some sort of error message or only a blank UIImageView space?