Refactor CocoaSetDockIcon function
Refactor CocoaSetDockIcon to improve structure and readability.
This commit is contained in:
parent
c468628564
commit
738b81aa50
|
|
@ -1,9 +1,14 @@
|
|||
#if defined(__APPLE__)
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <objc/runtime.h>
|
||||
#include "_cocoalayer.h"
|
||||
// Example: make a global function you can call
|
||||
extern "C" void CocoaSetDockIcon(unsigned char* data, int width, int height)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void CocoaSetDockIcon(unsigned char* data, int width, int height)
|
||||
{
|
||||
NSImage *dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
|
||||
CGDataProviderRef provider = CGDataProviderCreateWithData(nullptr, data, width*height*4, nullptr);
|
||||
|
|
@ -17,4 +22,10 @@ extern "C" void CocoaSetDockIcon(unsigned char* data, int width, int height)
|
|||
CGColorSpaceRelease(colorSpace);
|
||||
CGDataProviderRelease(provider);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user