Răsfoiți Sursa

Merge pull request #549 from onevcat/fix/scale-parameter-not-in-use

Remove scale parameter from round corner API
Wei Wang 9 ani în urmă
părinte
comite
420c62a9b2

+ 11 - 3
Sources/Image.swift

@@ -340,17 +340,17 @@ extension Kingfisher where Base: Image {
 
 // MARK: - Image Transforming
 extension Kingfisher where Base: Image {
+
     // MARK: - Round Corner
     /// Create a round corner image based on `self`.
     ///
     /// - parameter radius: The round corner radius of creating image.
     /// - parameter size:   The target size of creating image.
-    /// - parameter scale:  The image scale of creating image.
     ///
     /// - returns: An image with round corner of `self`.
     ///
     /// - Note: This method only works for CG-based image.
-    public func image(withRoundRadius radius: CGFloat, fit size: CGSize, scale: CGFloat) -> Image {
+    public func image(withRoundRadius radius: CGFloat, fit size: CGSize) -> Image {
         
         guard let cgImage = cgImage else {
             assertionFailure("[Kingfisher] Round corder image only works for CG-based image.")
@@ -856,7 +856,7 @@ extension Image {
     message: "Extensions directly on Image are deprecated. Use `kf.image(withRoundRadius:fit:scale:)` instead.",
     renamed: "kf.image")
     public func kf_image(withRoundRadius radius: CGFloat, fit size: CGSize, scale: CGFloat) -> Image {
-        return kf.image(withRoundRadius: radius, fit: size, scale: scale)
+        return kf.image(withRoundRadius: radius, fit: size)
     }
     
     // MARK: - Resize
@@ -936,3 +936,11 @@ extension Image {
         return kf.adjusted(brightness: brightness, contrast: contrast, saturation: saturation, inputEV: inputEV)
     }
 }
+
+extension Kingfisher where Base: Image {
+    @available(*, deprecated,
+    message: "`scale` is not used. Use the version without scale instead. (Remove the `scale` argument)")
+    public func image(withRoundRadius radius: CGFloat, fit size: CGSize, scale: CGFloat) -> Image {
+        return image(withRoundRadius: radius, fit: size)
+    }
+}

+ 1 - 1
Sources/ImageProcessor.swift

@@ -154,7 +154,7 @@ public struct RoundCornerImageProcessor: ImageProcessor {
         switch item {
         case .image(let image):
             let size = targetSize ?? image.kf.size
-            return image.kf.image(withRoundRadius: cornerRadius, fit: size, scale: options.scaleFactor)
+            return image.kf.image(withRoundRadius: cornerRadius, fit: size)
         case .data(_):
             return (DefaultImageProcessor.default >> self).process(item: item, options: options)
         }

+ 2 - 2
Tests/KingfisherTests/ImageDownloaderTests.swift

@@ -302,7 +302,7 @@ class ImageDownloaderTests: XCTestCase {
         let url = URL(string: URLString)!
         
         let p = RoundCornerImageProcessor(cornerRadius: 40)
-        let roundcornered = testImage.kf.image(withRoundRadius: 40, fit: testImage.kf.size, scale: 1)
+        let roundcornered = testImage.kf.image(withRoundRadius: 40, fit: testImage.kf.size)
         
         downloader.downloadImage(with: url, options: [.processor(p)], progressBlock: { (receivedSize, totalSize) -> () in
             
@@ -326,7 +326,7 @@ class ImageDownloaderTests: XCTestCase {
         let url = URL(string: URLString)!
         
         let p1 = RoundCornerImageProcessor(cornerRadius: 40)
-        let roundcornered = testImage.kf.image(withRoundRadius: 40, fit: testImage.kf.size, scale: 1)
+        let roundcornered = testImage.kf.image(withRoundRadius: 40, fit: testImage.kf.size)
 
         let p2 = BlurImageProcessor(blurRadius: 3.0)
         let blurred = testImage.kf.blurred(withRadius: 3.0)