开发者

Making an UIImage from byte string

开发者 https://www.devze.com 2023-02-17 22:10 出处:网络
I am paring a XML and getting an image in Byte form and I have put that in a string. Now I have to draw that image.

I am paring a XML and getting an image in Byte form and I have put that in a string. Now I have to draw that image.

I have tried to use various methods开发者_JAVA技巧 but no success. How can I do this?


Try converting the string to NSData:

NSString* str= ....
NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding]; 

Then take a look at:

UIImage *image = [[UIImage alloc] initWithData:data]; 

Hope this helps.


You can convert the byte into NSData and then you can get the image using

UIImage *image = [[UIImage alloc] initWithData:data];

OR

UIImage *image = [UIImage imageWithData:data];
0

精彩评论

暂无评论...
验证码 换一张
取 消