Last active
November 22, 2018 15:51
Revisions
-
cbess revised this gist
Nov 22, 2018 . No changes.There are no files selected for viewing
-
cbess revised this gist
Nov 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ @implementation NSView (Screenshot) /// Returns an image that contains the entire window contents, including window background color and traffic lights. /// Resembles the product of taking a screenshot using Preview.app - (NSImage *)screenshotOfWindow { CGWindowID winID = (CGWindowID) self.window.windowNumber; CGImageRef ref = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, winID, kCGWindowImageBoundsIgnoreFraming); return [[NSImage alloc] initWithCGImage:ref size:self.bounds.size]; -
cbess renamed this gist
Nov 22, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
cbess created this gist
Nov 22, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ // ref: https://stackoverflow.com/a/22967912/344591 @implementation NSView (Screenshot) /// Returns an image that contains the entire window contents, including window background color and traffic lights. /// Resembles the product of taking a screenshot using Preview.app - (NSImage *)screenshotFromDisplay { CGWindowID winID = (CGWindowID) self.window.windowNumber; CGImageRef ref = CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, winID, kCGWindowImageBoundsIgnoreFraming); return [[NSImage alloc] initWithCGImage:ref size:self.bounds.size]; } @end