问题描述
这两个功能目前是我的瓶颈。
如何提高性能? div>
您可以缓存较小版本的位图,您在绘制第一次之前创建,然后只需绘制缩减的示例,而不是完整的15万像素的东西。
然后再次确保你只是绘制什么是必要的,即在drawRect:(NSRect)rect'只绘制内部rect(除非绝对必要)。并且尽量不要在那个方法之外进行绘图。
Those two functions are currently my bottleneck. I am working with very large bitmaps.
How can I improve their performance?
You could cache smaller versions of your bitmaps which you create before drawing the first time and then simply draw the downscaled samples instead of the full-blown 15 megapixel stuff.
Then again make sure you are only drawing what is necessary i.e. in 'drawRect: (NSRect) rect' only draw inside the rect (unless absolutely necessary). And try not do perform drawings outside of that method.
这篇关于如何提高CGContextFillRect和CGContextDrawImage的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!