本文介绍了如何提高CGContextFillRect和CGContextDrawImage的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个功能目前是我的瓶颈。

解决方案



如何提高性能? 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的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-12 08:45