如何生成有效的NSImage暗图像?

时间:2019-11-24 04:41:10

标签: performance nsimage cgcontextdrawimage

大家好!

现在我已经遇到了有关NSImage的性能问题。 我想将NSImage转换为深色图像。我发现它太慢了。

我的代码如下:

myView.darkImage = [[NSImage alloc] initWithCGImage:imgRef size:mainFrame.size];
[myView.darkImage lockFocus];
[[NSColor colorWithCalibratedWhite:0 alpha:0.33] set];
NSRectFillUsingOperation(mainFrame, NSCompositingOperationSourceAtop);
[myView.darkImage unlockFocus];

,下面的代码非常慢:

[myView.darkImage lockFocus];

the lockfocus performance analysis chart is here

所以问题是: 如何获得有效的NSImage暗(灰色)图像?

任何想法将不胜感激!

0 个答案:

没有答案