Cocoa: Simplify qt_mac_cgimage_to_nsimage code
Since 10.6, NSImage has a sensible contructor for that. Change-Id: Ie753135ebb37630c1a70c395689bf85d4a4a01de Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
b67f4238b8
commit
0aa0675040
@ -124,16 +124,7 @@ CGImageRef qt_mac_image_to_cgimage(const QImage &img)
|
||||
|
||||
NSImage *qt_mac_cgimage_to_nsimage(CGImageRef image)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
NSImage *newImage = 0;
|
||||
NSRect imageRect = NSMakeRect(0.0, 0.0, CGImageGetWidth(image), CGImageGetHeight(image));
|
||||
newImage = [[NSImage alloc] initWithSize:imageRect.size];
|
||||
[newImage lockFocus];
|
||||
{
|
||||
CGContextRef imageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
||||
CGContextDrawImage(imageContext, *(CGRect*)&imageRect, image);
|
||||
}
|
||||
[newImage unlockFocus];
|
||||
NSImage *newImage = [[NSImage alloc] initWithCGImage:image size:NSZeroSize];
|
||||
return newImage;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user