By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Invert of background color

P: n/a
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

Apr 26 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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: ma**************@gmail.com [mailto:ma**************@gmail.com]
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

Apr 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.