tags:

views:

92

answers:

1

I use CGBitmapContextRef for large alterable image. Than I draw one's parts in UIView.drawRect. That's work well on iPhone 3GS - 17FPS. But on iPhone 4 calling subj method is very slow - and total FPS is 1.5!

profiler says that: on 3GS invokes CGSBlendBGRA8888toRGBA8888 which takes 23% of total time. on 4G same code invokes argb32_sample_RGBA32/argb32_image_mark which takes ~90%. wow!

Color space for bitmap is CGColorSpaceCreateDeviceRGB. And creating flag is kCGImageAlphaPremultipliedLast.

What can I do for better performance on iPhone 4 ? Any suggestions ?

+1  A: 

Try setting:

CGContextSetInterpolationQuality(myBitmapContext, kCGInterpolationNone);

on your bitmap. kCGInterpolationLow is another option.

Another technique that may help is add a CALayer to your view, and to set the CALayer's contents to your bitmap, instead of drawing the bitmap image inside the view's drawRect.

hotpaw2
Thanks. I tried yours techniques. 1) kCGInterpolationNone - bad quality for me when scaled. kCGInterpolationLow - good quality and FPS better a few (~5-10%). 2) CALayer.contents don't want to eat CGBitmapContext, just CGImage. But for that case I do next: /* must no ref for context-image when write into */ [.layer.contents = nil]; [change context's pixels]; [.layer.contents = CGBitmapContextCreateImage( pCtx)]; and that code on 3GS gives us 8FPS (was 17) and on 4G 12FPS (was 1.5)
... and clear .layer.contents and than setup one blink sometimes