Просмотр исходного кода

CGImage fix seems not necessary

onevcat 9 лет назад
Родитель
Сommit
b61cb6c970
1 измененных файлов с 2 добавлено и 25 удалено
  1. 2 25
      Sources/Image.swift

+ 2 - 25
Sources/Image.swift

@@ -403,7 +403,7 @@ extension Kingfisher where Base: Image {
     /// - Note: This method only works for CG-based image.
     public func resize(to size: CGSize) -> Image {
         
-        guard let cgImage = cgImage?.fixed else {
+        guard let cgImage = cgImage else {
             assertionFailure("[Kingfisher] Resize only works for CG-based image.")
             return base
         }
@@ -537,7 +537,7 @@ extension Kingfisher where Base: Image {
     /// - Note: This method only works for CG-based image.
     public func overlaying(with color: Color, fraction: CGFloat) -> Image {
         
-        guard let cgImage = cgImage?.fixed else {
+        guard let cgImage = cgImage else {
             assertionFailure("[Kingfisher] Overlaying only works for CG-based image.")
             return base
         }
@@ -721,29 +721,6 @@ extension CGSizeProxy {
     }
 }
 
-
-extension CGImage {
-    var isARGB8888: Bool {
-        return bitsPerPixel == 32 && bitsPerComponent == 8 && bitmapInfo.contains(.alphaInfoMask)
-    }
-    
-    var fixed: CGImage {
-        if isARGB8888 { return self }
-
-        // Convert to ARGB if it isn't
-        guard let context = CGContext.createARGBContext(from: self) else {
-            assertionFailure("[Kingfisher] Failed to create CG context when converting non ARGB image.")
-            return self
-        }
-        context.draw(self, in: CGRect(x: 0, y: 0, width: width, height: height))
-        guard let r = context.makeImage() else {
-            assertionFailure("[Kingfisher] Failed to create CG image when converting non ARGB image.")
-            return self
-        }
-        return r
-    }
-}
-
 extension CGBitmapInfo {
     var fixed: CGBitmapInfo {
         var fixed = self