From bed6776ca2bdb8a1f9fba988dc1bf82a0c38f56e Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sun, 6 Oct 2024 18:04:17 -0700 Subject: [PATCH 1/2] Fixed: default use high capture resolution in macos15 --- screen.go | 7 ++++--- screen/goScreen.h | 1 - screen/screengrab_c.h | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/screen.go b/screen.go index 9f8b28a..1e23bba 100644 --- a/screen.go +++ b/screen.go @@ -11,6 +11,7 @@ package robotgo import ( + "errors" "image" "github.com/kbinani/screenshot" @@ -53,9 +54,9 @@ func Capture(args ...int) (*image.RGBA, error) { // SaveCapture capture screen and save the screenshot to image func SaveCapture(path string, args ...int) error { - img, err := Capture(args...) - if err != nil { - return err + img := CaptureImg(args...) + if img == nil { + return errors.New("Capture image not found") } return Save(img, path) diff --git a/screen/goScreen.h b/screen/goScreen.h index d4349a5..1d93d07 100644 --- a/screen/goScreen.h +++ b/screen/goScreen.h @@ -12,7 +12,6 @@ #include "../base/pubs.h" #include "../base/rgb.h" #include "screengrab_c.h" -#include "screen_c.h" #include void padHex(MMRGBHex color, char* hex) { diff --git a/screen/screengrab_c.h b/screen/screengrab_c.h index 32c30f7..73dcac0 100644 --- a/screen/screengrab_c.h +++ b/screen/screengrab_c.h @@ -1,4 +1,5 @@ #include "../base/bitmap_free_c.h" +#include "screen_c.h" #include /* malloc() */ #if defined(IS_MACOSX) @@ -39,9 +40,12 @@ SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:target excludingWindows:@[]]; SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init]; + config.queueDepth = 5; config.sourceRect = diIntersectDisplayLocal; - config.width = diIntersectDisplayLocal.size.width; - config.height = diIntersectDisplayLocal.size.height; + config.width = diIntersectDisplayLocal.size.width * sys_scale(id); + config.height = diIntersectDisplayLocal.size.height * sys_scale(id); + config.scalesToFit = false; + config.captureResolution = 1; [SCScreenshotManager captureImageWithFilter:filter configuration:config From 75fd24ea0a32f764c249bd3ebc729d25bf4ddb09 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sun, 6 Oct 2024 18:11:23 -0700 Subject: [PATCH 2/2] Fixed: Fixed x11 build --- screen/screengrab_c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen/screengrab_c.h b/screen/screengrab_c.h index 73dcac0..579c380 100644 --- a/screen/screengrab_c.h +++ b/screen/screengrab_c.h @@ -1,5 +1,4 @@ #include "../base/bitmap_free_c.h" -#include "screen_c.h" #include /* malloc() */ #if defined(IS_MACOSX) @@ -14,6 +13,7 @@ #elif defined(IS_WINDOWS) #include #endif +#include "screen_c.h" #if defined(IS_MACOSX) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4 static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) {