Skip to content

Commit c4a01c9

Browse files
committed
Remove the extra cases for UIAnimatedImage, since SwiftUI may add support in the future. Currently grab the poster image does not do any performance benefit
1 parent 438994f commit c4a01c9

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,15 @@ public struct WebImage : View {
126126
func configure(image: PlatformImage) -> some View {
127127
// Actual rendering SwiftUI image
128128
let result: Image
129-
// NSImage works well with SwiftUI, include Animated and Vector Image
129+
// NSImage works well with SwiftUI, include Vector and EXIF images.
130130
#if os(macOS)
131131
result = Image(nsImage: image)
132132
#else
133-
// Fix the SwiftUI.Image rendering issue when use UIImage based, the `.aspectRatio` does not works. SwiftUI's Bug :)
133+
// Fix the SwiftUI.Image rendering issue, like when use EXIF UIImage, the `.aspectRatio` does not works. SwiftUI's Bug :)
134134
// See issue #101
135-
var image = image
136135
var cgImage: CGImage?
137-
// Case 1: UIAnimatedImage, grab poster image
138-
if image.sd_isAnimated {
139-
// check images property
140-
if let images = image.images, images.count > 0 {
141-
image = images[0]
142-
}
143-
}
144-
// Case 2: Vector Image, draw bitmap image
145-
else if image.sd_isVector {
136+
// Case 1: Vector Image, draw bitmap image
137+
if image.sd_isVector {
146138
// ensure CGImage is nil
147139
if image.cgImage == nil {
148140
// draw vector into bitmap with the screen scale (behavior like AppKit)
@@ -154,8 +146,8 @@ public struct WebImage : View {
154146
cgImage = image.cgImage
155147
}
156148
}
157-
// Case 3: Image with EXIF orientation
158-
if image.imageOrientation != .up {
149+
// Case 2: Image with EXIF orientation
150+
else if image.imageOrientation != .up {
159151
cgImage = image.cgImage
160152
}
161153
// If we have CGImage, use CGImage based API, else use UIImage based API

0 commit comments

Comments
 (0)