diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-16 22:50:25 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-16 22:50:25 -0400 |
| commit | aed66e27e37b85d20a49709f7ad2118fb7e8f796 (patch) | |
| tree | 66607e6cb7c1afa61b50f8e40453f7a36afee659 | |
| parent | ae7e86c24b6e853726beab12ff5b219cb9844fe4 (diff) | |
Fixed weird pixel corruption in the Mac OS X ImageList implementation (damn GC). Thanks to erica in irc.freenode.net/#macdev for guessing right and others for helping.
| -rw-r--r-- | redo/imagelist_darwin.m | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/redo/imagelist_darwin.m b/redo/imagelist_darwin.m index 00ad75a..7433b12 100644 --- a/redo/imagelist_darwin.m +++ b/redo/imagelist_darwin.m @@ -5,17 +5,14 @@ #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; + // we can't just hand it pixels; we need to make a copy bitmap = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:planes + initWithBitmapDataPlanes:NULL pixelsWide:toNSInteger(width) pixelsHigh:toNSInteger(height) bitsPerSample:8 @@ -26,6 +23,7 @@ id toImageListImage(void *pixels, intptr_t width, intptr_t height, intptr_t stri bitmapFormat:0 bytesPerRow:toNSInteger(stride) bitsPerPixel:32]; + memcpy((void *) [bitmap bitmapData], pixels, [bitmap bytesPerPlane]); image = [[NSImage alloc] initWithSize:NSMakeSize((CGFloat) width, (CGFloat) height)]; [image addRepresentation:bitmap]; return (id) image; |
