You can use NSBitmapImageRep to create an NSImage float-by-float.
Interestingly, one of its initializers has the longest method name in all Cocoa:
- (id)initWithBitmapDataPlanes:(unsigned char **)planes pixelsWide:(NSInteger)width pixelsHigh:(NSInteger)height bitsPerSample:(NSInteger)bps samplesPerPixel:(NSInteger)spp hasAlpha:(BOOL)alpha isPlanar:(BOOL)isPlanar colorSpaceName:(NSString *)colorSpaceName bitmapFormat:(NSBitmapFormat)bitmapFormat bytesPerRow:(NSInteger)rowBytes bitsPerPixel:(NSInteger)
This is well documented. Once you have built it by providing float arrays in planes , you can get NSImage to put in your view:
NSImage *image = [[NSImage alloc] initWithCGImage:[bitmapImageRep CGImage] size:NSMakeSize(width,height)];
Or, a little cleaner
NSImage *image = [[[NSImage alloc] init] autorelease]; [im addRepresentation:bitmapImageRep];
There is an initializer that simply uses the NSData container:
+ (id)imageRepWithData:(NSData *)bitmapData
although it depends on your bitmapData containing one of the correct bitmap formats.
source share