Created
January 27, 2013 09:12
-
-
Save chinmaygarde/4647506 to your computer and use it in GitHub Desktop.
Mac OSX Screen Capture
This file contains 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 characters
CGImageRef imageRef = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionAll, kCGNullWindowID, kCGWindowImageDefault); | |
CFMutableDataRef dataRef = CFDataCreateMutable(kCFAllocatorDefault, 0); | |
CGImageDestinationRef dest = CGImageDestinationCreateWithData(dataRef, kUTTypePNG, 1, NULL); | |
CGImageDestinationAddImage(dest, imageRef, NULL); | |
CGImageDestinationFinalize(dest); | |
CFRelease(dest); | |
CGImageRelease(imageRef); | |
// Do stuff with data | |
[(__bridge NSData *)dataRef writeToFile:@"/Users/Buzzy/Desktop/screen.png" atomically:YES]; | |
CFRelease(dataRef); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment