Created
May 23, 2011 21:01
-
-
Save jmoyers/987597 to your computer and use it in GitHub Desktop.
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
- (NSImage *)avatarIconForAvatar:(AvatarWrapper *)avatarWrapper | |
{ | |
CGFloat red = GetRValue(avatarWrapper.avatarData.color)/255.; | |
CGFloat blue = GetBValue(avatarWrapper.avatarData.color)/255.; | |
CGFloat green = GetGValue(avatarWrapper.avatarData.color)/255.; | |
NSImage *avatarBody = [[NSImage alloc] initWithContentsOfFile: | |
[[NSBundle mainBundle] pathForResource:@"avatar_icon_mask" ofType:@"png"]]; | |
NSImage *resultImage = [[[NSImage alloc] initWithSize:[avatarBody size]] autorelease]; | |
[resultImage lockFocus]; | |
NSBezierPath* thePath = [NSBezierPath bezierPath]; | |
[thePath appendBezierPathWithOvalInRect:NSMakeRect([avatarBody size].width * .10, | |
0, | |
[avatarBody size].width * .80, | |
[avatarBody size].height)]; | |
[[NSColor colorWithCalibratedRed:red green:green blue:blue alpha:1.0] setFill]; | |
[thePath fill]; | |
[avatarBody drawAtPoint:NSMakePoint(0, 0) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; | |
[resultImage unlockFocus]; | |
return resultImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment