Fix screenshot offset after pixel-exact crop change

The new CGImage.cropping path expects a top-left pixel rect; the previous
CGContext redraw had implicitly flipped Y. Keep the existing SCDisplay-space
conversion so the crop matches the selected region.

💘 Generated with Crush

Assisted-by: Crush:deepseek-v4-flash-0731
This commit is contained in:
2026-08-23 13:23:37 +08:00
parent 16b876807d
commit f50057d951
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -124,6 +124,9 @@ final class ScreenCapture {
let scaleX = CGFloat(image.width) / display.frame.width
let scaleY = CGFloat(image.height) / display.frame.height
guard scaleX > 0, scaleY > 0 else { return nil }
// pxRect is in image pixel space with a TOP-LEFT origin (SCDisplay space).
// CGImage.cropping(to:) expects the same top-left rect, so no Y flip
// is needed here — this preserves the previous CGContext behavior.
let pxRect = CGRect(
x: (cgRect.minX - display.frame.minX) * scaleX,
y: (cgRect.minY - display.frame.minY) * scaleY,