From 8e0ad4ac237d26e92ae104c7f49b04e7522e6957 Mon Sep 17 00:00:00 2001 From: onevcat Date: Wed, 28 Sep 2016 12:12:51 +0900 Subject: [PATCH] CGImage fix seems not necessary --- Sources/Image.swift | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/Sources/Image.swift b/Sources/Image.swift index 969906ef1..cf29ac4aa 100755 --- a/Sources/Image.swift +++ b/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