Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
694 views
in Technique[技术] by (71.8m points)

bitmap - CGContextDrawImage very slow on iPhone 4

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...