Invert of background color

  • Thread starter Thread starter mahesh.nimbalkar
  • Start date Start date
M

mahesh.nimbalkar

Hi,


I have color as System.Drawing.Color c1 object as background color.
Now I would like to get another System.Drawing.Color c2 object which
is invert of c1 color to be used as foreground color.


e.g if I have c1 as black and I should get c2 as white.


Thanks,

Mahesh
 
Use

public Color Invert(Color inputColor)
{
byte r = (byte)~(inputColor.R);
byte g = (byte)~(inputColor.G);
byte b = (byte)~(inputColor.B);

return Color.FromArgb(inputColor.A, r, g, b);
}

WBR, Alex Meleta
Blog: http://devkids.blogspot.com


-----Original Message-----
From: (e-mail address removed) [mailto:[email protected]]
Posted At: Donnerstag, 26. April 2007 21:37
Posted To: microsoft.public.dotnet.general
Conversation: Invert of background color
Subject: Invert of background color

Hi,


I have color as System.Drawing.Color c1 object as background color.
Now I would like to get another System.Drawing.Color c2 object which
is invert of c1 color to be used as foreground color.


e.g if I have c1 as black and I should get c2 as white.


Thanks,

Mahesh
 
Back
Top