Load NSImage into QPixmap or QImage

Posted by Thomi on Stack Overflow See other posts from Stack Overflow or by Thomi
Published on 2010-03-18T09:55:06Z Indexed on 2010/03/18 10:21 UTC
Read the original article Hit count: 696

Filed under:
|
|
|

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:

CGImageRef myImage = // ... get a CGImageRef somehow.
QImage img = QPixmap::fromMacCGImageRef(myImage).toImage();

However, I cannot find a way to convert from an NSImage to a CGImageRef. Several other people have had the same problem, but I have yet to find a solution.

There is the CGImageForProposedRect method, but I can't seem to get it to work. I'm currently trying this (img is my NSImage ptr):

CGImageRef ir = [img CGImageFirProposedRect:0:0:0];

Any ideas?

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt