Hi, I have a problem using hardware cursors on Mac. The same project works well on Linux and Windows.
On the left is how it should look, on the right its how it looks on Mac (a dotted line)
Hi, I have a problem using hardware cursors on Mac. The same project works well on Linux and Windows.
On the left is how it should look, on the right its how it looks on Mac (a dotted line)
Any update on this one?
Having the same issue here also, works fine in Windows except for Mac builds
Manage to fix mine, made some few changes in the MacCursor.cpp.
Here’s the code changes
void* FMacCursor::CreateCursorFromRGBABuffer(const FColor* Pixels, int32 Width, int32 Height, FVector2D InHotSpot)
{
NSBitmapImageRep* CursorImageRep = [
[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide : Width
pixelsHigh : Height
bitsPerSample : 8
samplesPerPixel : 4
hasAlpha : YES
isPlanar : NO
colorSpaceName : NSCalibratedRGBColorSpace
bitmapFormat : NSBitmapFormatAlphaFirst
bytesPerRow : Width * 4
bitsPerPixel : 32];
uint8* CursorPixels = [CursorImageRep bitmapData];
// for (int32 X = 0; X < Width; X++)
// {
// for (int32 Y = 0; Y < Height; Y++)
// {
// uint8* TargetPixel = (uint8*) CursorPixels + Y * Width + X * 4;
// *(uint32*) TargetPixel = *(((uint32*) Pixels) + (Y * Width) + X);
// }
// }
for( int I = 0; I < Width * Height; ++I )
{
uint8* TargetPixel = (uint8*) CursorPixels + I * 4;
*(uint32*) TargetPixel = *(((uint32*) Pixels) + I);
}
NSImage* CursorImage = [[NSImage alloc] initWithSize:NSMakeSize(Width, Height)];
[CursorImage addRepresentation : CursorImageRep];
const int32 PixelHotspotX = FMath::RoundToInt(InHotSpot.X * Width);
const int32 PixelHotspotY = FMath::RoundToInt(InHotSpot.Y * Height);
NSCursor* CursorHandle = [[NSCursor alloc] initWithImage:CursorImage hotSpot : NSMakePoint(PixelHotspotX, PixelHotspotY)];
[CursorImage release];
[CursorImageRep release];
return CursorHandle;
}
*Note: I’m loading my cursor images from color bitmap
Hi, using your code I see a cursor! Yay! But it seems the colors are wrong, like trasparent. Any suggestion on how to fix it? Maybe the colorSpaceName or bitmapFormat entries ?
In the picture below, the left is how it should be, the right how I see it.
Nice!
Hi, using your code I see a cursor! Yay! But it seems the colors are wrong, like trasparent. Any suggestion on how to fix it? Maybe the colorSpaceName or bitmapFormat entries ?
In the picture below, the left is how it should be, the right how I see it.
Not really sure, maybe you need to re-arrange your colour format?
Mac colour format is ARGB maybe you’re passing it as BGRA format?
Hi, I used
bitmapFormat : NSBitmapFormatAlphaNonpremultiplied
instead of
bitmapFormat : NSBitmapFormatAlphaFirst
and it works! My images are PNG images. I can now see the icon properly.