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!

  • Could you attach a screenshot of what it's supposed to look like, and what it looks like after snapshotting? – smokris Mar 01 '12 at 18:15

2 Answers2

0

The obliteration of antialiasing might have something to do with alpha-transparency. As the lowest layer in your Composition, do you have a Clear patch set to opaque black? (It defaults to transparent black, which might be causing the problem here.)

smokris
  • 11,740
  • 2
  • 39
  • 59
  • Thanks for the suggestion, but unfortunately this didn't help. It seems to be unrelated to the parameters of my Clear patch. I did notice that changing my lines to solid black (they were a shade of grey) slightly improves the fidelity of the image, if this could be a clue at all. – user1238705 Mar 01 '12 at 14:47
0

Thanks smokris, but I found that the way to do this is to take a CGImage snapshot. I thought I'd be able to put this snapshot in an IKImageView, which preserves anti-aliasing, but IKImageView suffers from the same issue QCView, in that when print is called you get nothing in your print window.

So, the method that finally worked is to create pdf data from the CGImage snapshot using a CGPDFContext, load up an NSImageView with an NSImage generated from this pdf data, and when this goes to a print window all anti-aliasing is preserved! Very roundabout, but works like charm!