What I'm trying to achieve:
At the moment, I have a UIImagePickerController set up to take a picture, and return it as a small-sized photo (about 300 x 500ish pixels).
By default, the image obtained from the image picker is full resolution - i.e. quite large. So before doing anything with this image, I resize it:
UIGraphicsBeginImageContext(targetSize);
CGRect thumbnailRect = CGRectZero;
thumbnailRect.origin = thumbnailPoint;
thumbnailRect.size.width = scaledWidth;
thumbnailRect.size.height = scaledHeight;
[sourceImage drawInRect:thumbnailRect];
newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
-
What doesn't work so well:
This step is quite resource intensive, in fact it freezes the app for several seconds during the operation. I haven't tried it on an iPhone 4, but I can imagine it will only be worse with HD images.
Aside from being resource intensive, getting this photo also seems to use up a very large amount of memory for a small period of time, often resulting in the app crashing. I am assuming that this memory is from the large sized images that are being captured at first.
-
So:
What it the best/standard method of getting small images from UIImagePicker? I don't want my app to freeze or crash due to high CPU or RAM usage. Surely there must be a better, more stable and efficient way?
Any help is much appreciated :)