Browse Source

Always use rgb space for color hex on macOS

onevcat 8 years ago
parent
commit
69ad8ca99a
1 changed files with 6 additions and 2 deletions
  1. 6 2
      Sources/ImageProcessor.swift

+ 6 - 2
Sources/ImageProcessor.swift

@@ -694,9 +694,13 @@ fileprivate extension Color {
         var g: CGFloat = 0
         var b: CGFloat = 0
         var a: CGFloat = 0
-        
+
+        #if os(macOS)
+        (usingColorSpace(NSColorSpace.deviceRGB) ?? self).getRed(&r, green: &g, blue: &b, alpha: &a)
+        #else
         getRed(&r, green: &g, blue: &b, alpha: &a)
-        
+        #endif
+
         let rInt = Int(r * 255) << 24
         let gInt = Int(g * 255) << 16
         let bInt = Int(b * 255) << 8