How do I invert a colour?
Posted
by ThePower
on Stack Overflow
See other posts from Stack Overflow
or by ThePower
Published on 2009-07-22T13:01:44Z
Indexed on
2010/04/17
23:03 UTC
Read the original article
Hit count: 204
I know that this won't directly invert a colour, it will just 'oppose' it. I was wondering if anyone knew a simple way (a few lines of code) to invert a colour from any given colour?
At the moment I have this (which isn't exactly the definition of an invert):
const int RGBMAX = 255;
Color InvertMeAColour(Color ColourToInvert)
{
return Color.FromArgb(RGBMAX - ColourToInvert.R,
RGBMAX - ColourToInvert.G, RGBMAX - ColourToInvert.B);
}
© Stack Overflow or respective owner