From 6a3b936d0f0e95e80c515ca87eff175d8a429530 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 1 Jun 2017 15:10:09 +0200 Subject: [PATCH] use built-in that exists since 10.6 --- src/osx/carbon/utilscocoa.mm | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/osx/carbon/utilscocoa.mm b/src/osx/carbon/utilscocoa.mm index c3f2c11501..5742c8468c 100644 --- a/src/osx/carbon/utilscocoa.mm +++ b/src/osx/carbon/utilscocoa.mm @@ -403,7 +403,6 @@ wxBitmap wxOSXCreateSystemBitmap(const wxString& name, const wxString &WXUNUSED( return wxBitmap( [NSImage imageNamed:cfname.AsNSString()] ); } -// From "Cocoa Drawing Guide:Working with Images" WX_NSImage wxOSXGetNSImageFromCGImage( CGImageRef image, double scaleFactor, bool isTemplate ) { NSRect imageRect = NSMakeRect(0.0, 0.0, 0.0, 0.0); @@ -412,25 +411,10 @@ WX_NSImage wxOSXGetNSImageFromCGImage( CGImageRef image, double scaleFactor, bo imageRect.size.height = CGImageGetHeight(image)/scaleFactor; imageRect.size.width = CGImageGetWidth(image)/scaleFactor; - // Create a new image to receive the Quartz image data. - NSImage *newImage = [[NSImage alloc] initWithSize:imageRect.size]; - [newImage lockFocus]; - - // Get the Quartz context and draw. - CGContextRef imageContext = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; - CGContextDrawImage( imageContext, *(CGRect*)&imageRect, image ); - [newImage unlockFocus]; - + NSImage* newImage = [[NSImage alloc] initWithCGImage:image size:imageRect.size]; + [newImage setTemplate:isTemplate]; - /* - // Create a bitmap rep from the image... - NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; - // Create an NSImage and add the bitmap rep to it... - NSImage *image = [[NSImage alloc] init]; - [image addRepresentation:bitmapRep]; - [bitmapRep release]; - */ [newImage autorelease]; return( newImage ); }