The blog has moved to a new address. The blog is now located at http://devintelligence.com

Adsense

Tuesday, January 09, 2007

A function to calculate the opposite color of given color

/// <summary>
/// Calculates the opposite color
/// </summary>
/// <param name="clr">Given color</param>
/// <returns></returns>
public static Color CalculateOppositeColor(Color clr)
{
return Color.FromArgb(255 - clr.R, 255 - clr.G, 255 - clr.B);
}

3 comments:

Anonymous said...

Thanks

Anonymous said...

yeh cheers for this!

Anonymous said...

Well, not a good idea. One can see it in some programs when the background is gray (128, 128, 128) - then the opposite color would be 127,127,127 - for the human eye is impossible to distinguish. The marker or selection box is lost agaist the gray background.