Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert data to image in iOS

Tags:

ios

NSData *imageData = UIImagePNGRepresentation(your_image_here);

After that i transferred it to another iPhone using bluetooth. Now i need to convert the data back to image. Can any one tell me how to do it?


1 Answers

I assume this is to et back the data which you encoded in the previous question. For converting UIImage to NSData ,

NSData* pictureData = UIImagePNGRepresentation(image);

To get it back,

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

Remember to add [image release] at the end.

or you can use

UIImage *image = [[UIImage alloc]init];
[image imageWithData:pictureData];
like image 105
Nithin Avatar answered Dec 10 '25 01:12

Nithin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!