+ wxAutoNSAutoreleasePool pool;
+ if(!CocoaTakeFocus()) return;
+ if(!bmp.Ok())
+ return;
+
+#if 0
+ // Draw a rect so we can see where it's supposed to be
+ wxLogTrace(wxTRACE_COCOA,wxT("image at (%d,%d) size %dx%d"),x,y,bmp.GetWidth(),bmp.GetHeight());
+ NSBezierPath *bezpath = [NSBezierPath bezierPathWithRect:NSMakeRect(x,y,bmp.GetWidth(),bmp.GetHeight())];
+ [[NSColor blackColor] set];
+ [bezpath stroke];
+ [[NSColor blueColor] set];
+ [bezpath fill];
+#endif // 0
+
+ NSAffineTransform *transform = [NSAffineTransform transform];
+ [transform translateXBy:x yBy:y];
+
+ NSAffineTransform *flipTransform = [NSAffineTransform transform];
+ /* x' = 1x + 0y + 0
+ y' = 0x + -1y + window's height
+ */
+ NSAffineTransformStruct matrix = {
+ 1, 0
+ , 0, -1
+ , 0, bmp.GetHeight()
+ };
+ [flipTransform setTransformStruct: matrix];
+
+ NSGraphicsContext *context = [NSGraphicsContext currentContext];
+ [context saveGraphicsState];
+ [transform concat];
+ [flipTransform concat];
+
+ NSImage *nsimage = [bmp.GetNSImage(useMask) retain];
+
+ [nsimage drawAtPoint: NSMakePoint(0,0)
+ fromRect: NSMakeRect(0.0,0.0,bmp.GetWidth(),bmp.GetHeight())
+ operation: NSCompositeSourceOver
+ fraction: 1.0];
+
+ [nsimage release];
+ [context restoreGraphicsState];