From f50057d951f50ea75fe73f84c87e6a037e0cc610 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Sun, 23 Aug 2026 13:23:37 +0800 Subject: [PATCH] Fix screenshot offset after pixel-exact crop change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Sources/Kapture/CaptureController.swift | 3 +++ build-app.sh | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/Kapture/CaptureController.swift b/Sources/Kapture/CaptureController.swift index 7b15ce1..9df7235 100644 --- a/Sources/Kapture/CaptureController.swift +++ b/Sources/Kapture/CaptureController.swift @@ -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, diff --git a/build-app.sh b/build-app.sh index 531be5d..df558df 100755 --- a/build-app.sh +++ b/build-app.sh @@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST' CFBundleIconFile Icon CFBundleShortVersionString - 1.3.0 + 1.3.1 CFBundleVersion - 30 + 31 LSUIElement NSHighResolutionCapable