diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-16 21:49:43 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-16 21:49:43 -0400 |
| commit | 5903dffe3c3f4572491c6575d431f066faa03caf (patch) | |
| tree | ecd8f87191bf297461eb2b0baac17135f8b6feac /redo/imagelist_darwin.m | |
| parent | 37069eadcbd8960ac46031b3455f78463a6bdf3f (diff) | |
Implemented ImageList and Table ImageIndex on Mac OS X.
Diffstat (limited to 'redo/imagelist_darwin.m')
| -rw-r--r-- | redo/imagelist_darwin.m | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/redo/imagelist_darwin.m b/redo/imagelist_darwin.m new file mode 100644 index 0000000..00ad75a --- /dev/null +++ b/redo/imagelist_darwin.m @@ -0,0 +1,32 @@ +// 16 august 2014 + +#import "objc_darwin.h" +#import <Cocoa/Cocoa.h> + +#define toNSInteger(x) ((NSInteger) (x)) + +// TODO top two pixels of 16x16 images are green? + +id toImageListImage(void *pixels, intptr_t width, intptr_t height, intptr_t stride) +{ + unsigned char *planes[1]; // NSBitmapImageRep wants an array of planes; we have one plane + NSBitmapImageRep *bitmap; + NSImage *image; + + planes[0] = (unsigned char *) pixels; + bitmap = [[NSBitmapImageRep alloc] + initWithBitmapDataPlanes:planes + pixelsWide:toNSInteger(width) + pixelsHigh:toNSInteger(height) + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSDeviceRGBColorSpace + bitmapFormat:0 + bytesPerRow:toNSInteger(stride) + bitsPerPixel:32]; + image = [[NSImage alloc] initWithSize:NSMakeSize((CGFloat) width, (CGFloat) height)]; + [image addRepresentation:bitmap]; + return (id) image; +} |
