Skip to content

Fixed: default use high capture resolution in macos15 #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package robotgo

import (
"errors"
"image"

"github.com/kbinani/screenshot"
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion screen/goScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "../base/pubs.h"
#include "../base/rgb.h"
#include "screengrab_c.h"
#include "screen_c.h"
#include <stdio.h>

void padHex(MMRGBHex color, char* hex) {
Expand Down
8 changes: 6 additions & 2 deletions screen/screengrab_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#elif defined(IS_WINDOWS)
#include <string.h>
#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) {
Expand All @@ -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
Expand Down
Loading