Why is the image captured by `SCScreenshotManager.captureImage` so blurry?

I am using ScreenCaptureKit to create a screenshot software, but I found that the screenshot captured by the new API, SCScreenshotManager.captureImage, is very blurry.

This is my screenshot. It is so blurry.

But I hope it's like this.

My code is as follows.

func captureScreen(windows: [SCWindow], display: SCDisplay) async throws -> CGImage? {
    let availableWindows = windows.filter { window in
        Bundle.main.bundleIdentifier != window.owningApplication?.bundleIdentifier
    }

    let filter = SCContentFilter(display: display, including: availableWindows)

    if #available(macOS 14.0, *) {
        let image = try? await SCScreenshotManager.captureImage(
                contentFilter: filter,
                configuration: SCStreamConfiguration.defaultConfig(
                        width: display.width,
                        height: display.height
                )
        )
        return image
    } else {
        return nil
    }
}
extension SCStreamConfiguration {
    static func defaultConfig(width: Int, height: Int) -> SCStreamConfiguration {
        let config = SCStreamConfiguration()
        config.width = width
        config.height = height
        config.showsCursor = false
        if #available(macOS 14.0, *) {
            config.captureResolution = .best
        }
        return config
    }
}

Accepted Reply

Note that SCDisplay’s width and height properties are specified in points, while SCStreamConfiguration may expect width and height to be specified in pixels.

Replies

Note that SCDisplay’s width and height properties are specified in points, while SCStreamConfiguration may expect width and height to be specified in pixels.