[tcobrowser-cvs] SF.net SVN: tcobrowser:[1060] trunk/bibdesk/NSColor_Conversion.m
Status: Beta
Brought to you by:
amaxwell
From: <ama...@us...> - 2009-01-29 00:29:57
|
Revision: 1060 http://tcobrowser.svn.sourceforge.net/tcobrowser/?rev=1060&view=rev Author: amaxwell Date: 2009-01-29 00:29:53 +0000 (Thu, 29 Jan 2009) Log Message: ----------- assert parameters as non-nil, fix comments Modified Paths: -------------- trunk/bibdesk/NSColor_Conversion.m Modified: trunk/bibdesk/NSColor_Conversion.m =================================================================== --- trunk/bibdesk/NSColor_Conversion.m 2009-01-29 00:22:51 UTC (rev 1059) +++ trunk/bibdesk/NSColor_Conversion.m 2009-01-29 00:29:53 UTC (rev 1060) @@ -57,22 +57,24 @@ NSString * BDSKColorAs32BitString(NSColor *aColor) { + NSCParameterAssert(nil != aColor); _RGBAFloatColor floatColor; [[aColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&floatColor.r green:&floatColor.g blue:&floatColor.b alpha:&floatColor.a]; - // store a 32 bit color instead of the floating point values + // save space by storing a 32 bit color instead of the floating point values _RGBAInt u; u.rgba.r = floatColor.r * 255; u.rgba.g = floatColor.g * 255; u.rgba.b = floatColor.b * 255; u.rgba.a = floatColor.a * 255; - // note: use %d here to correspond to -[NSString intValue] usage, even though it looks wrong, it preserves all the bits + // Note: use %d here to correspond to -[NSString intValue] usage; it looks wrong, but it preserves all the bits. return ((u.rgba.r > 245 && u.rgba.g > 245 && u.rgba.b > 245) || 0 == u.rgba.a) ? nil : [NSString stringWithFormat:@"%d", CFSwapInt32HostToBig(u.intValue)]; } NSColor * BDSKColorFrom32BitString(NSString *aString) { + NSCParameterAssert(nil != aString); _RGBAInt u; - // string may be a signed value, but interpret as unsigned; see note above + // String may be a signed value, but interpret as unsigned; see note above. u.intValue = CFSwapInt32BigToHost([aString intValue]); _RGBAFloatColor floatColor = { u.rgba.r / 255.0, u.rgba.g / 255.0, u.rgba.b / 255.0, u.rgba.a / 255.0 }; return [NSColor colorWithCalibratedRed:floatColor.r green:floatColor.g blue:floatColor.b alpha:floatColor.a]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |