title: Load NSImage into QPixmap or QImage
body: <p>I have an NSImage pointer from a platform SDK, and I need to load it into Qt's QImage class. To make things easier, I can create a QImage from a CGImageRef by using QPixmap as an intermediate format, like this:</p>
  
  <pre><code>CGImageRef myImage = // ... get a CGImageRef somehow.
  QImage img = QPixmap::fromMacCGImageRef(myImage).toImage();
  </code></pre>
  
  <p>However, I cannot find a way to convert from an NSImage to a CGImageRef. <a href="http://lists.apple.com/archives/quartz-dev/2007/Jul/msg00046.html" rel="nofollow noreferrer">Several</a> <a href="http://www.cocoadev.com/index.pl?ConvertNSImageToCGImage" rel="nofollow noreferrer">other people</a> have had the same problem, but I have yet to find a solution.</p>
  
  <p>There is the <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/Reference/Reference.html#//apple_ref/occ/instm/NSImage/CGImageForProposedRect:context:hints:" rel="nofollow noreferrer"><code>CGImageForProposedRect</code></a> method, but I can't seem to get it to work. I'm currently trying this (<code>img</code> is my NSImage ptr):</p>
  
  <pre><code>CGImageRef ir = [img CGImageFirProposedRect:0:0:0];
  </code></pre>
  
  <p>Any ideas?</p>