1

I have put much time and effort into drawing certain 3d plots and surfaces using a Quartz Composition. Everything looks wonderful in my (Cocoa) application's QCView. However, in order to print, I am taking a snapshot of the QCView to generate an NSImage, and putting that in an NSView for my print options screen. However, lines and colors in the snapshot look horrendously aliased. Is there some other way to either directly print from my QCView, or to bypass/override taking a snapshot so that the NSImage looks as good as what's in my QCView? QCView inherits from NSView, but the built-in print method doesn't seem to work.

Thanks!

4

2 回答 2

0

消除抗锯齿可能与 alpha 透明度有关。作为合成中的最低层,您是否将透明色块设置为不透明黑色?(它默认为透明黑色,这可能会导致这里出现问题。)

于 2012-02-29T21:33:15.827 回答
0

谢谢 smokris,但我发现这样做的方法是拍摄 CGImage 快照。我想我可以把这个快照放在一个 IKImageView 中,它保留了抗锯齿,但是 IKImageView 遇到了同样的问题 QCView,因为当调用 print 时,你的打印窗口中什么也没有。

因此,最终奏效的方法是使用 CGPDFContext 从 CGImage 快照创建 pdf 数据,使用从该 pdf 数据生成的 NSImage 加载 NSImageView,当它进入打印窗口时,所有抗锯齿都被保留!非常迂回,但就像魅力一样!

于 2012-03-01T22:35:12.333 回答