I have the following code to set cursor from existing CGImage:
NSPoint hotspot = ...;
CGImageRef cgimg = ...;
if(!cgimg)
return nullptr;
NSImage* nsimg = [[NSImage alloc] initWithCGImage:cgimg size:NSZeroSize];
if(!nsimg)
return nullptr;
NSCursor* pcur = [[NSCursor alloc] initWithImage: nsimg hotSpot: hotspot];
if(!pcur)
return nullptr;
[nsimg release];
// later in the code I set it as current:
[pcur set];
Problem is that it renders inconsistently, sometimes it looks OK, sometimes it shows garbage:
I am using exactly the same CGImageRef that is rendered OK as normal image (that one below the box).
Any idea what problem could be?
Stock cursors in the same application are rendered OK. That is on OS X "El Capitan" if that matters.