When I get imageWithSystemSymbolName, I get black graphics on a transparent background. How can I get white symbols?
When I look at the symbols (like triangle.circle) in SF Symbols, they're all white on transparent. For example, I want to draw triangle.circle.fill on a black screen, so I don't want a black image.
I'm doing something like this to get SF Symbols (as NSData to pass them as a byte array into Unity):
When I look at the symbols (like triangle.circle) in SF Symbols, they're all white on transparent. For example, I want to draw triangle.circle.fill on a black screen, so I don't want a black image.
I'm doing something like this to get SF Symbols (as NSData to pass them as a byte array into Unity):
Code Block objc NSData* GetSymbolImageAsBytes(int width, int height) { GCController *gc = [GCController current]; NSString *name = gc.extendedGamepad.buttonY.sfSymbolsName; NSImage *image = [NSImage imageWithSystemSymbolName: name accessibilityDescription: nil ]; // https://stackoverflow.com/a/38442746/79125 NSSize size = NSMakeSize(width, height); NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:size.width pixelsHigh:size.height bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0]; rep.size = size; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:rep]]; [image drawInRect:NSMakeRect(0, 0, size.width, size.height) fromRect:NSZeroRect operation:NSCompositingOperationCopy fraction:1.0]; [NSGraphicsContext restoreGraphicsState]; if (rep == nil) { return nil; } // Passing nil gives a warning but seems to work okay. return [rep representationUsingType:NSBitmapImageFileTypePNG properties:nil]; }