Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions Source/Internal/Graphics/PDFGraphics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,21 @@ internal enum PDFGraphics {
height: floor(frame.height * resizeFactor))

#if os(iOS)
UIGraphicsBeginImageContext(size)
image.draw(in: CGRect(origin: .zero, size: size))
let finalImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

return finalImage ?? image
var finalImage: UIImage = image
if #available(iOS 17.0, *) {
if let cgImage = image.cgImage {
finalImage = UIGraphicsImageRenderer(size: size).image { renderContext in
let rect = CGRect(origin: .zero, size: size)
renderContext.cgContext.draw(image: cgImage, in: rect, flipped: true)
}
}
} else {
UIGraphicsBeginImageContext(size)
image.draw(in: CGRect(origin: .zero, size: size))
finalImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
UIGraphicsEndImageContext()
}
return finalImage
#elseif os(macOS)
let finalImage = NSImage(size: size)
finalImage.lockFocus()
Expand Down