Skip to content

Commit

Permalink
Fix build on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Sep 8, 2024
1 parent 81276af commit 404cd08
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Sources/Pulse/Helpers/ImageProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ import ImageIO
#endif

enum Graphics {
static func resize(_ image: UIImage, to size: CGSize) -> PlatformImage? {
#if os(macOS)
static func resize(_ image: PlatformImage, to size: CGSize) -> PlatformImage? {
#if canImport(UIKit)
UIGraphicsBeginImageContextWithOptions(size, false, 1.0)
image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
let thumbnail = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return thumbnail
#elseif canImport(AppKit)
let newImage = NSImage(size: newSize)
newImage.lockFocus()
let sourceRect = NSMakeRect(0, 0, size.width, size.height)
Expand All @@ -29,11 +35,7 @@ enum Graphics {
newImage.unlockFocus()
return newImage
#else
UIGraphicsBeginImageContextWithOptions(size, false, 1.0)
image.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
let thumbnail = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return thumbnail
return image
#endif
}

Expand Down

0 comments on commit 404cd08

Please sign in to comment.