Panic on American ApparelCar in Snow, Part 5Car in Snow, Part 4Car in Snow, Part 3

fill the void

Posts from January 2010

Cocoa Tip: NSImage Composites

Recently, I wanted to composite together two images, much like Tweetie’s retweet UI for avatars: display the main icon in its original size but overlay a second icon smaller and offset. Turns out to be only a couple lines of code using NSImage:

NSImage *mainIcon = [NSImage imageNamed:@"main_icon"];
NSImage *overlayIcon = [NSImage imageNamed:@"overlay_icon"];
[mainIcon lockFocus];
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
[overlayIcon drawInRect:NSMakeRect([mainIcon [...]