-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
388f93e
commit 2e1e22e
Showing
5 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
using SharpMetal.Foundation; | ||
using SharpMetal.ObjectiveCCore; | ||
|
||
namespace SharpMetal.QuartzCore | ||
{ | ||
public enum ColorSpace | ||
{ | ||
DisplayP3, | ||
DisplayP3HLG, | ||
ExtendedLinearDisplayP3, | ||
SRGB, | ||
LinearSRGB, | ||
ExtendedSRGB, | ||
ExtendedLinearSRGB, | ||
GenericGrayGamma22, | ||
LinearGray, | ||
ExtendedGray, | ||
ExtendedLinearGray, | ||
GenericRGBLinear, | ||
GenericCMYK, | ||
GenericXYZ, | ||
GenericLab, | ||
ACESCGLinear, | ||
AdobeRGB1998, | ||
DCIP3, | ||
ITUR709, | ||
ROMMRGB, | ||
ITUR2020, | ||
ExtendedLinearITUR2020 | ||
} | ||
|
||
[SupportedOSPlatform("macos")] | ||
public partial struct CGColorSpace | ||
{ | ||
private const string CoreGraphicsFramework = "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics"; | ||
|
||
[LibraryImport(CoreGraphicsFramework)] | ||
private static partial IntPtr CGColorSpaceCreateWithName(IntPtr name); | ||
|
||
private static NSString GetString(ColorSpace colorSpace) | ||
{ | ||
var colorSpaceName = colorSpace switch | ||
Check warning on line 44 in src/SharpMetal/QuartzCore/CGColorSpace.cs GitHub Actions / build / build
|
||
{ | ||
ColorSpace.DisplayP3 => "kCGColorSpaceDisplayP3", | ||
ColorSpace.DisplayP3HLG => "kCGColorSpaceDisplayP3_HLG", | ||
ColorSpace.ExtendedLinearDisplayP3 => "kCGColorSpaceExtendedLinearDisplayP3", | ||
ColorSpace.SRGB => "kCGColorSpaceSRGB", | ||
ColorSpace.LinearSRGB => "kCGColorSpaceLinearSRGB", | ||
ColorSpace.ExtendedSRGB => "kCGColorSpaceExtendedSRGB", | ||
ColorSpace.ExtendedLinearSRGB => "kCGColorSpaceExtendedLinearSRGB", | ||
ColorSpace.GenericGrayGamma22 => "kCGColorSpaceGenericGrayGamma2_2", | ||
ColorSpace.LinearGray => "kCGColorSpaceLinearGray", | ||
ColorSpace.ExtendedGray => "kCGColorSpaceExtendedGray", | ||
ColorSpace.ExtendedLinearGray => "kCGColorSpaceExtendedLinearGray", | ||
ColorSpace.GenericRGBLinear => "kCGColorSpaceGenericRGBLinear", | ||
ColorSpace.GenericCMYK => "kCGColorSpaceGenericCMYK", | ||
ColorSpace.GenericXYZ => "kCGColorSpaceGenericXYZ", | ||
ColorSpace.GenericLab => "kCGColorSpaceGenericLab", | ||
ColorSpace.ACESCGLinear => "kCGColorSpaceACESCGLinear", | ||
ColorSpace.AdobeRGB1998 => "kCGColorSpaceAdobeRGB1998", | ||
ColorSpace.DCIP3 => "kCGColorSpaceDCIP3", | ||
ColorSpace.ITUR709 => "kCGColorSpaceITUR_709", | ||
ColorSpace.ROMMRGB => "kCGColorSpaceROMMRGB", | ||
ColorSpace.ITUR2020 => "kCGColorSpaceITUR_2020", | ||
ColorSpace.ExtendedLinearITUR2020 => "kCGColorSpaceExtendedLinearITUR_2020", | ||
}; | ||
|
||
return new(ObjectiveC.IntPtr_objc_msgSend(new ObjectiveCClass("NSString"), "stringWithUTF8String:", colorSpaceName)); | ||
} | ||
|
||
public static IntPtr CreateCGColorSpace(ColorSpace colorSpace) | ||
{ | ||
return CGColorSpaceCreateWithName(GetString(colorSpace)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters