@@ -124,7 +124,6 @@ public struct WebImage : View {
124
124
125
125
/// Configure the platform image into the SwiftUI rendering image
126
126
func configure( image: PlatformImage ) -> some View {
127
- var image = image
128
127
// Actual rendering SwiftUI image
129
128
let result : Image
130
129
// NSImage works well with SwiftUI, include Animated and Vector Image
@@ -133,6 +132,8 @@ public struct WebImage : View {
133
132
#else
134
133
// Fix the SwiftUI.Image rendering issue when use UIImage based, the `.aspectRatio` does not works. SwiftUI's Bug :)
135
134
// See issue #101
135
+ var image = image
136
+ var cgImage : CGImage ?
136
137
// Case 1: UIAnimatedImage, grab poster image
137
138
if image. sd_isAnimated {
138
139
// check images property
@@ -147,14 +148,21 @@ public struct WebImage : View {
147
148
// draw vector into bitmap with the screen scale (behavior like AppKit)
148
149
UIGraphicsBeginImageContextWithOptions ( image. size, false , UIScreen . main. scale)
149
150
image. draw ( at: . zero)
150
- image = UIGraphicsGetImageFromCurrentImageContext ( ) ?? . empty
151
+ cgImage = UIGraphicsGetImageFromCurrentImageContext ( ) ? . cgImage
151
152
UIGraphicsEndImageContext ( )
153
+ } else {
154
+ cgImage = image. cgImage
152
155
}
153
156
}
157
+ // Case 3: Image with EXIF orientation
158
+ if image. imageOrientation != . up {
159
+ cgImage = image. cgImage
160
+ }
154
161
// If we have CGImage, use CGImage based API, else use UIImage based API
155
- if let cgImage = image. cgImage {
162
+ if let cgImage = cgImage {
163
+ let scale = image. scale
156
164
let orientation = image. imageOrientation. toSwiftUI
157
- result = Image ( decorative: cgImage, scale: image . scale, orientation: orientation)
165
+ result = Image ( decorative: cgImage, scale: scale, orientation: orientation)
158
166
} else {
159
167
result = Image ( uiImage: image)
160
168
}
0 commit comments