diff options
author | Neil <nyamatongwe@gmail.com> | 2017-04-22 15:20:04 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2017-04-22 15:20:04 +1000 |
commit | 85f3d56133f6b74ee7ed4f18648fa1e8fcf1d6bf (patch) | |
tree | bd3dd53de70c7afa3bc9645bd9cff62c736de3d6 | |
parent | 2bd1d204b9b539bc6cea8b69864c586e0e1b465c (diff) | |
download | scintilla-mirror-85f3d56133f6b74ee7ed4f18648fa1e8fcf1d6bf.tar.gz |
Simplify NSImage creation by using its initWithCGImage directly instead of
creating an NSBitmapImageRep first.
-rw-r--r-- | cocoa/PlatCocoa.mm | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 8f26420a1..4cdf6716d 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1377,11 +1377,8 @@ static NSImage* ImageFromXPM(XPM* pxpm) SurfaceImpl* surfaceIXPM = static_cast<SurfaceImpl*>(surfaceXPM); CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height)); pxpm->Draw(surfaceXPM, rcxpm); - img = [[[NSImage alloc] initWithSize:NSZeroSize] autorelease]; CGImageRef imageRef = surfaceIXPM->GetImage(); - NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; - [img addRepresentation: bitmapRep]; - [bitmapRep release]; + img = [[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize]; CGImageRelease(imageRef); delete surfaceXPM; } @@ -1862,25 +1859,21 @@ void ListBoxImpl::RegisterImage(int type, const char* xpm_data) } } -void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) { - CGImageRef imageRef = ImageCreateFromRGBA(width, height, pixelsImage, false); - NSSize sz = {static_cast<CGFloat>(width), static_cast<CGFloat>(height)}; - NSImage *img = [[[NSImage alloc] initWithSize: sz] autorelease]; - NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; - [img addRepresentation: bitmapRep]; - [bitmapRep release]; - CGImageRelease(imageRef); - [img retain]; - ImageMap::iterator it=images.find(type); - if (it == images.end()) - { - images[type] = img; - } - else - { - [it->second release]; - it->second = img; - } +void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) +{ + CGImageRef imageRef = ImageCreateFromRGBA(width, height, pixelsImage, false); + NSImage *img = [[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize]; + CGImageRelease(imageRef); + ImageMap::iterator it=images.find(type); + if (it == images.end()) + { + images[type] = img; + } + else + { + [it->second release]; + it->second = img; + } } void ListBoxImpl::ClearRegisteredImages() |