diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-07-11 15:14:13 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-07-11 16:42:01 +0200 |
commit | 3ef6cf060e984bca43956a23b61b32ec7347cfc7 (patch) | |
tree | 14810e4d0168c0cc3d69cb286574bf28375c07bc /src/plugins/platforms/cocoa/qcocoahelpers.mm | |
parent | b06304e164ba47351fa292662c1e6383c081b5ca (diff) | |
parent | 7b9d6cf844ece18fef884f51117e25ad4ac31db5 (diff) |
Merge branch 'stable' into dev
Conflicts:
qmake/generators/mac/pbuilder_pbx.cpp
src/corelib/json/qjsonwriter.cpp
src/corelib/kernel/qeventdispatcher_blackberry.cpp
src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
Change-Id: I24df576c4cbd18fa51b03122f71e32bb83b9028f
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoahelpers.mm | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 8ab1d9b579..3be294de7e 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -84,11 +84,8 @@ static void drawImageReleaseData (void *info, const void *, size_t) CGImageRef qt_mac_image_to_cgimage(const QImage &img) { - if (img.width() <= 0 || img.height() <= 0) { - qWarning() << Q_FUNC_INFO << - "trying to set" << img.width() << "x" << img.height() << "size for CGImage"; + if (img.isNull()) return 0; - } QImage *image; if (img.depth() != 32) @@ -124,16 +121,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; } @@ -148,6 +136,24 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm) return nsImage; } +NSImage *qt_mac_create_nsimage(const QIcon &icon) +{ + if (icon.isNull()) + return nil; + + NSImage *nsImage = [[NSImage alloc] init]; + foreach (QSize size, icon.availableSizes()) { + QPixmap pm = icon.pixmap(size); + QImage image = pm.toImage(); + CGImageRef cgImage = qt_mac_image_to_cgimage(image); + NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; + [nsImage addRepresentation:imageRep]; + [imageRep release]; + CGImageRelease(cgImage); + } + return nsImage; +} + HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion ®ion) { HIMutableShapeRef shape = HIShapeCreateMutable(); |