Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImage UIImageJPEGRepresentation safe to UIImage

I need to perform UIImageJPEGRepresentation method and after that save it NOT to file, I need to save it to UIImage. Help please..

like image 724
LightNight Avatar asked Jul 21 '11 12:07

LightNight


People also ask

What is the difference between UIImage and UIImageView?

UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .

How do you declare UIImage in Objective C?

For example: UIImage *img = [[UIImage alloc] init]; [img setImage:[UIImage imageNamed:@"anyImageName"]]; My UIImage object is declared in .


2 Answers

you can use this:

NSData *imageData = UIImageJPEGRepresentation(uiimageObject,1.0);

UIImage *imageObj = [UIImage imageWithData:imageData];
like image 151
Satish Azad Avatar answered Oct 02 '22 18:10

Satish Azad


I have no idea why you are wanting to go from a UIImage to jpeg data and then right back to a UIImage, but [UIImage imageWithData:jpegdata] should do it.

like image 35
Anomie Avatar answered Oct 02 '22 18:10

Anomie