diff options
Diffstat (limited to 'bleh_darwin.m')
| -rw-r--r-- | bleh_darwin.m | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/bleh_darwin.m b/bleh_darwin.m index 331e2ca..a8febcf 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -109,45 +109,3 @@ because @encode() is NOT A LITERAL, we're going to just stick it all the way bac see also: http://stackoverflow.com/questions/6812035/adding-methods-dynamically */ char *encodedNSRect = @encode(NSRect); - -/* -the NSBitmapImageRep constructor is complex; put it here -the only way to draw a NSBitmapImageRep in a flipped NSView is to use the most complex drawing method; put it here too -*/ - -/* -hey guys you know what's fun? 32-bit ABI changes! -*/ -static BOOL (*objc_msgSend_drawInRect)(id, SEL, NSRect, NSRect, NSCompositingOperation, CGFloat, BOOL, id) = - (BOOL (*)(id, SEL, NSRect, NSRect, NSCompositingOperation, CGFloat, BOOL, id)) objc_msgSend; - -void drawImage(void *pixels, int64_t width, int64_t height, int64_t stride, int64_t xdest, int64_t ydest) -{ - unsigned char *planes[1]; /* NSBitmapImageRep wants an array of planes; we have one plane */ - id bitmap; - - bitmap = objc_msgSend(c_NSBitmapImageRep, s_alloc); - planes[0] = (unsigned char *) pixels; - bitmap = objc_msgSend(bitmap, s_initWithBitmapDataPlanes, - planes, /* initWithBitmapDataPlanes: */ - (NSInteger) width, /* pixelsWide: */ - (NSInteger) height, /* pixelsHigh: */ - (NSInteger) 8, /* bitsPerSample: */ - (NSInteger) 4, /* samplesPerPixel: */ - (BOOL) YES, /* hasAlpha: */ - (BOOL) NO, /* isPlanar: */ - NSCalibratedRGBColorSpace, /* colorSpaceName: | TODO NSDeviceRGBColorSpace? */ - (NSBitmapFormat) 0, /* bitmapFormat: | this is where the flag for placing alpha first would go if alpha came first; the default is alpha last, which is how we're doing things (otherwise the docs say "Color planes are arranged in the standard order—for example, red before green before blue for RGB color."); this is also where the flag for non-premultiplied colors would go if we used it (the default is alpha-premultiplied) */ - (NSInteger) stride, /* bytesPerRow: */ - (NSInteger) 32); /* bitsPerPixel: */ - /* TODO this CAN fail; check error */ - objc_msgSend_drawInRect(bitmap, s_drawInRect, - NSMakeRect((CGFloat) xdest, (CGFloat) ydest, - (CGFloat) width, (CGFloat) height), /* drawInRect: */ - NSZeroRect, /* fromRect: | draw whole image */ - (NSCompositingOperation) NSCompositeSourceOver, /* op: */ - (CGFloat) 1.0, /* fraction: */ - (BOOL) YES, /* respectFlipped: */ - nil); /* hints: */ - objc_msgSend(bitmap, s_release); -} |
