如何使用整个部分而不只是 mac 上的可见部分制作卷轴 window 的屏幕截图
How to make a screen cut of a scroll window with the whole part not only the visible part on mac
我正在mac OS X上写一个截屏APP,我只能得到window的可见部分,像这样:
CGImageRef imageRef = CGWindowListCreateImage(CGRectNull,
kCGWindowListOptionIncludingWindow,
self.windowID,
kCGWindowImageBoundsIgnoreFraming);
_windowImage = [[NSImage alloc] initWithCGImage:imageRef size:self.windowFrame.size];
CGImageRelease(imageRef);
但是当 window 可以滚动时,我想获得整个部分而不仅仅是可见部分,有人有什么建议吗?
谢谢!
//capture 获取scrollview的截图
NSRect bounds = NSMakeRect(0, 0, [self.scrollView.documentView frame].size.width,[self.scrollView.documentView frame].size.height);
// //只能获取可见部分 only can grap the visible part of the scrollview
// NSBitmapImageRep* captureImage = [(NSView *)self.scrollView.documentView bitmapImageRepForCachingDisplayInRect:bounds];
// [self.scrollView cacheDisplayInRect:bounds toBitmapImageRep:captureImage];
// NSImage *image = [[NSImage alloc] initWithCGImage:[captureImage CGImage] size:captureImage.size];
//can grab the whole part
[self.scrollView lockFocus];
NSImage *image = [[NSImage alloc] initWithData:[(NSView *)self.scrollView.documentView
dataWithPDFInsideRect:bounds]];
[self.scrollView unlockFocus];
我正在mac OS X上写一个截屏APP,我只能得到window的可见部分,像这样:
CGImageRef imageRef = CGWindowListCreateImage(CGRectNull,
kCGWindowListOptionIncludingWindow,
self.windowID,
kCGWindowImageBoundsIgnoreFraming);
_windowImage = [[NSImage alloc] initWithCGImage:imageRef size:self.windowFrame.size];
CGImageRelease(imageRef);
但是当 window 可以滚动时,我想获得整个部分而不仅仅是可见部分,有人有什么建议吗? 谢谢!
//capture 获取scrollview的截图
NSRect bounds = NSMakeRect(0, 0, [self.scrollView.documentView frame].size.width,[self.scrollView.documentView frame].size.height);
// //只能获取可见部分 only can grap the visible part of the scrollview
// NSBitmapImageRep* captureImage = [(NSView *)self.scrollView.documentView bitmapImageRepForCachingDisplayInRect:bounds];
// [self.scrollView cacheDisplayInRect:bounds toBitmapImageRep:captureImage];
// NSImage *image = [[NSImage alloc] initWithCGImage:[captureImage CGImage] size:captureImage.size];
//can grab the whole part
[self.scrollView lockFocus];
NSImage *image = [[NSImage alloc] initWithData:[(NSView *)self.scrollView.documentView
dataWithPDFInsideRect:bounds]];
[self.scrollView unlockFocus];