mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NSColor to java.awt.Color
This commit is contained in:
@@ -214,4 +214,19 @@ public class MacUtil {
|
||||
cfRelease((ID)activity);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Color colorFromNative(ID color) {
|
||||
final ID colorSpace = invoke("NSColorSpace", "genericRGBColorSpace");
|
||||
final ID colorInSpace = invoke(color, "colorUsingColorSpace:", colorSpace);
|
||||
final long red = invoke(colorInSpace, "redComponent").longValue();
|
||||
final long green = invoke(colorInSpace, "greenComponent").longValue();
|
||||
final long blue = invoke(colorInSpace, "blueComponent").longValue();
|
||||
final long alpha = invoke(colorInSpace, "alphaComponent").longValue();
|
||||
//noinspection UseJBColor
|
||||
return new Color((float)Double.longBitsToDouble(red),
|
||||
(float)Double.longBitsToDouble(green),
|
||||
(float)Double.longBitsToDouble(blue),
|
||||
(float)Double.longBitsToDouble(alpha));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user