Here’s the code I have but it’s crashing … any ideas?
UIImage *tempImage = [[UIImage alloc] initWithData:imageData];
CGImageRef imgRef = [tempImage CGImage];
[tempImage release];
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
CGRect bounds = CGRectMake(0, 0, width, height);
CGSize size = bounds.size;
CGAffineTransform transform = CGAffineTransformMakeScale(4.0, 4.0);
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextConcatCTM(context, transform);
CGContextDrawImage(context, bounds, imgRef);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
What am I missing here? Basically just trying to scale image up and crop it to be same size as original.
Thanks
The problem is this line:
Or more precise, the direct follow-up of this line:
You are getting a CF object here, the
CGImageRef. Core Foundation object only have the retain/release memory management, but no autoreleased objects. Hence, when you release theUIImagein the second row, theCGImageRefwill be deleted as well. And this again means that it’s undefined when you try to draw it down there.I can think of three fixes:
[tempImage autorelease];CFRetainandCFRelease.