Skip to content

Commit 2e2bed1

Browse files
authored
fix: scale screen recorder properly (#124)
2 parents 1ecd270 + f94b51e commit 2e2bed1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ishare/Capture/ScreenRecorder.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ class ScreenRecorder: ObservableObject {
120120
private func startCapture(with filter: SCContentFilter, fileURL: URL) async {
121121
@Default(.useHDR) var useHDR
122122

123-
let config: SCStreamConfiguration
124-
if useHDR {
125-
config = SCStreamConfiguration(preset: .captureHDRStreamCanonicalDisplay)
126-
} else {
127-
config = SCStreamConfiguration()
128-
}
123+
let ptRect = filter.contentRect
124+
let pxScale = CGFloat(filter.pointPixelScale)
125+
let pxRect = CGRect(x: ptRect.origin.x * pxScale, y: ptRect.origin.y * pxScale, width: ptRect.width * pxScale, height: ptRect.height * pxScale)
126+
127+
let config = useHDR ? SCStreamConfiguration(preset: .captureHDRStreamCanonicalDisplay) : SCStreamConfiguration()
128+
config.width = Int(round(pxRect.width / 2) * 2)
129+
config.height = Int(round(pxRect.height / 2) * 2)
130+
config.scalesToFit = false
129131

130132
isRunning = true
131133

0 commit comments

Comments
 (0)