1
我想用C/C++在OSX上截屏。 到目前为止,这是我得到:使用C++和CGWindow API的OSX屏幕截图
#import <ApplicationServices/ApplicationServices.h>
int main(int argc, char** argv) {
CGImageRef screenShot = CGWindowListCreateImage(CGRectInfinite,
kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
CFStringRef file = CFSTR("/Users/aduh/Desktop/lala.jpg");
CFStringRef type = CFSTR("public.jpeg");
CFURLRef urlRef = CFURLCreateWithString(NULL, file, NULL);
CGImageDestinationRef idst = CGImageDestinationCreateWithURL(urlRef, type, 1, NULL);
CGImageDestinationAddImage(idst, screenShot, NULL);
CGImageDestinationFinalize(idst);}
它编译罚款,但没有真正发生。我可能只是犯了一个愚蠢的错误,所以如果任何人都可以指出我的方向是正确的,那就太好了!