Skip to content

Instantly share code, notes, and snippets.

@DylanLukes
Created September 24, 2010 23:10
Show Gist options
  • Save DylanLukes/596210 to your computer and use it in GitHub Desktop.
Save DylanLukes/596210 to your computer and use it in GitHub Desktop.
GLvoid* load_image(NSString* imagename){
CGImageRef img = [[NSImage imageNamed:imagename] CGImage];
if(!img) NSLog(@"Image loading failed for \"%@\"", imagename);
NSInteger width = CGImageGetWidth(img);
NSInteger height = CGImageGetHeight(img);
unsigned char *data = (unsigned char*) malloc(width*height*4);
// Create a context to draw the new bitmap into
CGContextRef context = CGBitmapContextCreate(data, width, height, 8, width * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedLast);
CGContextDrawImage(context, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), img);
CGContextRelease(context);
return NULL;
}
2010-09-24 19:10:48.587 Concorde[44543:a0f] -[NSImage CGImage]: unrecognized selector sent to instance 0x1001357b0
2010-09-24 19:10:48.593 Concorde[44543:a0f] An uncaught exception was raised
2010-09-24 19:10:48.594 Concorde[44543:a0f] Unlocking Focus on wrong view (<NSThemeFrame: 0x100321550>), expected <CNWorldView: 0x10030a6e0>
2010-09-24 19:10:48.596 Concorde[44543:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unlocking Focus on wrong view (<NSThemeFrame: 0x100321550>), expected <CNWorldView: 0x10030a6e0>'
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff88427cc4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff83a160f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff88427ae7 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff88427a74 +[NSException raise:format:] + 148
4 AppKit 0x00007fff86605637 -[NSView unlockFocus] + 98
5 AppKit 0x00007fff865f6bb9 -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 3738
6 AppKit 0x00007fff8656fff6 -[NSView displayIfNeeded] + 969
7 AppKit 0x00007fff86538027 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1050
8 AppKit 0x00007fff86537bbe -[NSWindow orderWindow:relativeTo:] + 94
9 AppKit 0x00007fff86503bbc -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1726
10 AppKit 0x00007fff86501cd9 loadNib + 226
11 AppKit 0x00007fff865011e9 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
12 AppKit 0x00007fff86501021 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
13 AppKit 0x00007fff864fe5a3 NSApplicationMain + 279
14 Concorde 0x0000000100001437 main + 39
15 Concorde 0x00000001000013e4 start + 52
16 ??? 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment