Skip to content

Instantly share code, notes, and snippets.

@atsuya
Created August 17, 2014 07:35
Show Gist options
  • Save atsuya/492438d53130bd8325a3 to your computer and use it in GitHub Desktop.
Save atsuya/492438d53130bd8325a3 to your computer and use it in GitHub Desktop.
rendering nsimage with CGContextDrawImage using TwUI
CGContextRef ctx = TUIGraphicsGetCurrentContext();
NSImage *image = [NSImage imageNamed:@"Logo"];
CGRect imageRect = ABIntegralRectWithSizeCenteredInRect([image size], self.bounds);
CGImageRef cgImage = [image CGImageForProposedRect:&imageRect context:nil hints:nil];
CGContextDrawImage(ctx, imageRect, cgImage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment