Wednesday, June 19, 2013

Get underlying NSData* from UIImage http://stackoverflow.com/questions/4623931/get-underlying-nsdata-from-uiimage

http://stackoverflow.com/questions/4623931/get-underlying-nsdata-from-uiimage

Get underlying NSData* from UIImage

I can create UIImage from NSData using [UIImage imageWithdata:] or [UIImage initWithData] method.

I wonder if I can get the NSData* back from an existing UIImage* ?
something on the line of NSData* myData = [myImage getData];

Is this impossible?
Thank you

  NSData *imageData = UIImageJPEGRepresentation(image, 0.7); // 0.7 is JPG quality

or

  NSData *imageData = UIImagePNGRepresentation(image);

Depending if you want your data in PNG format or JPG format.

No comments:

Post a Comment