Skip to content

Commit 404cd08

Browse files
committed
Fix build on macOS
1 parent 81276af commit 404cd08

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Sources/Pulse/Helpers/ImageProcessor.swift

+9-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ import ImageIO
1919
#endif
2020

2121
enum Graphics {
22-
static func resize(_ image: UIImage, to size: CGSize) -> PlatformImage? {
23-
#if os(macOS)
22+
static func resize(_ image: PlatformImage, to size: CGSize) -> PlatformImage? {
23+
#if canImport(UIKit)
24+
UIGraphicsBeginImageContextWithOptions(size, false, 1.0)
25+
image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
26+
let thumbnail = UIGraphicsGetImageFromCurrentImageContext()
27+
UIGraphicsEndImageContext()
28+
return thumbnail
29+
#elseif canImport(AppKit)
2430
let newImage = NSImage(size: newSize)
2531
newImage.lockFocus()
2632
let sourceRect = NSMakeRect(0, 0, size.width, size.height)
@@ -29,11 +35,7 @@ enum Graphics {
2935
newImage.unlockFocus()
3036
return newImage
3137
#else
32-
UIGraphicsBeginImageContextWithOptions(size, false, 1.0)
33-
image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
34-
let thumbnail = UIGraphicsGetImageFromCurrentImageContext()
35-
UIGraphicsEndImageContext()
36-
return thumbnail
38+
return image
3739
#endif
3840
}
3941

0 commit comments

Comments
 (0)