Reputation: 953
I am recieving array of bytes from JSON webservice and it is a jpg image. i want to convert this byte array into image. on server side these bytes are correct and can be converted into image. But in Xcod i am unable to convert it into image. I have tried following Links but unable to convert bytes into image
How to get UIImage from Byte...at IPhone code
Encode Byte array to JPEG image in Objective-C
Byte Array to UIImage Objective-C
Upvotes: 0
Views: 4616
Reputation: 3980
You can do like this
UIImage *image = [[UIImage alloc]initWithData:pictureData];
assuming pictureData is of type NSData
.
In order to convert your byte array to NSData you pass the pointer to the char array accordingly:
NSData *pictureData = [NSData dataWithBytes:pointer];
Upvotes: 0
Reputation: 2186
You can get the bytes in NSData and use the NSData to get the image in an UIImage object. Use initWithData method. Hope this helps
Upvotes: 1