resize the camera. The UIImage returned by the UIImagePickerController takes a ridiculously long time if you do it in the usual way, as in this post .
[update: last call for creative ideas here! my next option is to ask Apple, I think.]
Yes, itโs a lot of pixels, but the graphic equipment on the iPhone is perfectly capable of drawing a lot of textured squares in size of 1024x1024 on the screen in 1/60 second, so there really should be a way to resize a 2048x1536 image to 640x480 in a lot less than 1.5 seconds.
So why is it so slow? Is the basic image data that the OS returns from the collector somehow not ready to draw, so it needs to be pumped up in some way that the GPU cannot handle?
My best guess: it needs to be converted from RGBA to ABGR or something like that; can anyone think about how to convince the system to quickly provide me with data, even if it is not in the correct format, and I will deal with it later?
As far as I know, the iPhone does not have a dedicated โgraphicโ memory, so there should be no question of moving image data from one place to another.
So the question is: is there any alternative drawing method besides using CGBitmapContextCreate and CGContextDrawImage that takes more advantage of the GPU?
Something to explore: if I start with a UIImage of the same size that is not using the image picker, is it also slow? Apparently not ...
Update: Matt Long discovered that it took only 30 ms to resize the image you are returning from the collector in [info objectForKey:@"UIImagePickerControllerEditedImage"] if you enabled cropping using the manual camera controls. This is not useful for the case where I care about where I use takePicture to take pictures programmatically. I see that the edited image is kCGImageAlphaPremultipliedFirst , but the original image is kCGImageAlphaNoneSkipFirst .
Further update: Jason Crawford proposed CGContextSetInterpolationQuality(context, kCGInterpolationLow) , which actually reduces the time from 1.5 s to 1.3 s at a cost in image quality - but this is still far from the speed that the GPU should be capable of!
Last update before the end of the week : user refulgentis did some profiling, which seems to indicate that 1.5 seconds was spent writing the captured camera image to a JPEG disc, and then reading it in. If true, itโs very strange.