Skip to content

Instantly share code, notes, and snippets.

@tmdvs
Created May 29, 2012 13:22
Show Gist options
  • Save tmdvs/2828360 to your computer and use it in GitHub Desktop.
Save tmdvs/2828360 to your computer and use it in GitHub Desktop.
// Get the data into a bitmap.
[self lockFocus];
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[self bounds]];
[self unlockFocus];
// Make an NSImage from our bitmap.
image = [[[NSImage alloc] initWithSize:[rep size]] autorelease];
[image addRepresentation:rep];
NSData * tiffData = [image TIFFRepresentationUsingCompression: NSTIFFCompressionNone factor: 0.0f];
CIImage *backgroundCIImage = [[CIImage alloc] initWithData:tiffData];
CIContext *ciContext = [[NSGraphicsContext currentContext] CIContext];
[ciContext drawImage:backgroundCIImage atPoint:CGPointZero fromRect:someRect];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment