Skip to content

Commit 217d6cf

Browse files
authored
Merge pull request #692 from go-vgo/bitmap-pr
Fixed: default use high capture resolution in macos15
2 parents 1923d7b + 75fd24e commit 217d6cf

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

screen.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package robotgo
1212

1313
import (
14+
"errors"
1415
"image"
1516

1617
"github.com/kbinani/screenshot"
@@ -53,9 +54,9 @@ func Capture(args ...int) (*image.RGBA, error) {
5354

5455
// SaveCapture capture screen and save the screenshot to image
5556
func SaveCapture(path string, args ...int) error {
56-
img, err := Capture(args...)
57-
if err != nil {
58-
return err
57+
img := CaptureImg(args...)
58+
if img == nil {
59+
return errors.New("Capture image not found")
5960
}
6061

6162
return Save(img, path)

screen/goScreen.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "../base/pubs.h"
1313
#include "../base/rgb.h"
1414
#include "screengrab_c.h"
15-
#include "screen_c.h"
1615
#include <stdio.h>
1716

1817
void padHex(MMRGBHex color, char* hex) {

screen/screengrab_c.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#elif defined(IS_WINDOWS)
1414
#include <string.h>
1515
#endif
16+
#include "screen_c.h"
1617

1718
#if defined(IS_MACOSX) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4
1819
static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) {
@@ -39,9 +40,12 @@
3940

4041
SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:target excludingWindows:@[]];
4142
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
43+
config.queueDepth = 5;
4244
config.sourceRect = diIntersectDisplayLocal;
43-
config.width = diIntersectDisplayLocal.size.width;
44-
config.height = diIntersectDisplayLocal.size.height;
45+
config.width = diIntersectDisplayLocal.size.width * sys_scale(id);
46+
config.height = diIntersectDisplayLocal.size.height * sys_scale(id);
47+
config.scalesToFit = false;
48+
config.captureResolution = 1;
4549

4650
[SCScreenshotManager captureImageWithFilter:filter
4751
configuration:config

0 commit comments

Comments
 (0)