inverse color

  • Thread starter Thread starter Smokey Grindle
  • Start date Start date
S

Smokey Grindle

How can you "inverse" a color in GDI+? Say the color I have is blue, the
inverse of that is yellow... how would you go about doing this? is there a
simpler way then taking the RGB values and takeing the difference from 255?

Say blue is 0,0,255
the inverse would be 255,255,0 which is yellow, is masking this the only way
to go?

0 0 255
- 255 255 255
==============
-255 -255 0

ABS(result) = 255,255,0

? or am i going the wrong way with this and there is an easier way. thanks!
 
hi Smokey

Dim OriginalColor As Color = Color.RoyalBlue
Dim InverseColor As Color = Color.FromArgb(Not OriginalColor.R,
Not OriginalColor.G, Not OriginalColor.B)

-t

Smokey Grindle ha scritto:
 
Switch the operators in the subtraction, and you don't get a negative value:

255 - r, 255 - g, 255 - b

You can also use exclusive or:

r xor 255, g xor 255, b xor 255
 
Smokey said:
How can you "inverse" a color in GDI+? Say the color I have is blue, the
inverse of that is yellow... how would you go about doing this? is there a
simpler way then taking the RGB values and takeing the difference from 255?

Say blue is 0,0,255
the inverse would be 255,255,0 which is yellow, is masking this the only way
to go?

Not sure, but be aware that by this rule the inverse of medium gray
(808080) is... another medium gray (7f7f7f)
0 0 255
- 255 255 255
==============
-255 -255 0

Subtract the other way round.
ABS(result) = 255,255,0

? or am i going the wrong way with this and there is an easier way. thanks!

If there were such a method it would be in Color, I imagine, and there
isn't one there. You might find a recent thread we had here about RGB -
HSL conversion interesting.
 
Back
Top