Mutablegopi
Mutablegopi

Reputation: 281

Memory leak application crashing while converting uiimage to nsdata

My application crashing while am converting uiimage to nsdata, I got this message in my console.

 " Received memory warning"  

And my application get crashing.

Am using this below code to converting uiimage to nsdata,

 NSData *imageData = UIImageJPEGRepresentation(image, 90);

Then am using this below code to convert nsdata to uiimage:

   CFDataRef imgData;
    CGDataProviderRef imgDataProvider;
    CGImageRef image1;
    imgData = (CFDataRef)CFBridgingRetain([arraydata objectAtIndex:0]);
    imgDataProvider = CGDataProviderCreateWithCFData (imgData);
    CFRelease(imgData);
    image1 = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault);
    CGDataProviderRelease(imgDataProvider);

    imageView.image = CFBridgingRelease(image1);

    CGImageRelease(image1);

Can any one help me to out of this issue?.

Upvotes: 4

Views: 286

Answers (1)

Amrendra Pratap Singh
Amrendra Pratap Singh

Reputation: 661

Try converting NSdata to image like this:

imageView.image = [UIImage imageWithData:imageData];

Upvotes: 1

Related Questions