Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bc93c2014 | ||
|
|
374af50acc |
@@ -86,8 +86,10 @@ final class ScreenCapture {
|
|||||||
|
|
||||||
@available(macOS 14.0, *)
|
@available(macOS 14.0, *)
|
||||||
private func crop(_ image: CGImage, to rect: NSRect, display: SCDisplay) -> CGImage? {
|
private func crop(_ image: CGImage, to rect: NSRect, display: SCDisplay) -> CGImage? {
|
||||||
let scaleX = CGFloat(display.width) / display.frame.width
|
// Scale from the actual captured image dimensions, which reflect the
|
||||||
let scaleY = CGFloat(display.height) / display.frame.height
|
// stream's pixel output (retina => 2x, non-retina => 1x).
|
||||||
|
let scaleX = CGFloat(image.width) / display.frame.width
|
||||||
|
let scaleY = CGFloat(image.height) / display.frame.height
|
||||||
let cgRect = CGRect(
|
let cgRect = CGRect(
|
||||||
x: rect.minX,
|
x: rect.minX,
|
||||||
y: rect.minY,
|
y: rect.minY,
|
||||||
@@ -133,8 +135,13 @@ final class ScreenCapture {
|
|||||||
let excluded = content.windows.filter { excludedSet.contains($0.windowID) }
|
let excluded = content.windows.filter { excludedSet.contains($0.windowID) }
|
||||||
let filter = SCContentFilter(display: display, excludingWindows: excluded)
|
let filter = SCContentFilter(display: display, excludingWindows: excluded)
|
||||||
let config = SCStreamConfiguration()
|
let config = SCStreamConfiguration()
|
||||||
config.width = Int(display.width)
|
// width/height are in points. Use the display's backing scale so
|
||||||
config.height = Int(display.height)
|
// retina captures come out at full pixel resolution.
|
||||||
|
let backingScale = NSScreen.screens.first(where: { $0.frame.contains(
|
||||||
|
NSPoint(x: rect.midX, y: rect.midY)
|
||||||
|
) })?.backingScaleFactor ?? 2
|
||||||
|
config.width = Int(display.frame.width * backingScale)
|
||||||
|
config.height = Int(display.frame.height * backingScale)
|
||||||
config.showsCursor = true
|
config.showsCursor = true
|
||||||
|
|
||||||
guard let image = try? await SCScreenshotManager.captureImage(contentFilter: filter, configuration: config) else {
|
guard let image = try? await SCScreenshotManager.captureImage(contentFilter: filter, configuration: config) else {
|
||||||
|
|||||||
@@ -193,12 +193,16 @@ struct ResultView: View {
|
|||||||
.padding(.top, 10)
|
.padding(.top, 10)
|
||||||
|
|
||||||
if model.mode == .screenshot {
|
if model.mode == .screenshot {
|
||||||
Image(nsImage: NSImage(cgImage: model.image, size: .zero))
|
GeometryReader { geo in
|
||||||
.resizable()
|
let imageWidth = CGFloat(model.image.width)
|
||||||
.interpolation(.none)
|
Image(nsImage: NSImage(cgImage: model.image, size: .zero))
|
||||||
.aspectRatio(contentMode: .fit)
|
.resizable()
|
||||||
.border(Color.secondary.opacity(0.4))
|
// Downscale with smoothing (AA); upscale keeps pixels crisp.
|
||||||
.padding(.horizontal, 12)
|
.interpolation(imageWidth >= geo.size.width ? .high : .none)
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
}
|
||||||
|
.border(Color.secondary.opacity(0.4))
|
||||||
|
.padding(.horizontal, 12)
|
||||||
} else {
|
} else {
|
||||||
ZStack(alignment: .bottomTrailing) {
|
ZStack(alignment: .bottomTrailing) {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
|
|||||||
+2
-2
@@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST'
|
|||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>Icon</string>
|
<string>Icon</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.1.1</string>
|
<string>1.1.3</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>11</string>
|
<string>13</string>
|
||||||
<key>LSUIElement</key>
|
<key>LSUIElement</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user