vla*_*r z 7 drawing image objective-c uiimage ios
这正是它所需要的,除了它需要大约400毫秒,这是350毫秒太多:
- (void) updateCompositeImage { //blends together the background and the sprites
UIGraphicsBeginImageContext(CGSizeMake(480, 320));
[bgImageView.image drawInRect:CGRectMake(0, 0, 480, 320)];
for (int i=0;i<numSprites;i++) {
[spriteImage[spriteType[i]] drawInRect:spriteRect[i] blendMode:kCGBlendModeScreen alpha:spriteAlpha[i]];
}
compositeImageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
Run Code Online (Sandbox Code Playgroud)
图像相当小,只有三个(for循环只迭代两次)
有没有办法更快地做到这一点?虽然仍然可以使用kCGBlendModeScreen和alpha?
您可以:
使用CoreGraphics本身可能会更快.另一个好处是你可以在后台线程上执行渲染.还要考虑如何使用Instruments优化该循环和配置文件.
其他考虑:
归档时间: |
|
查看次数: |
4570 次 |
最近记录: |