inverse color

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Smokey Grindle

    #1

    inverse color

    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!


  • tommaso.gastaldi@uniroma1.it

    #2
    Re: inverse color

    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:
    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!

    Comment

    • Göran Andersson

      #3
      Re: inverse color

      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 Grindle wrote:
      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!
      >
      >

      Comment

      • Larry Lard

        #4
        Re: inverse color

        Smokey Grindle wrote:
        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.

        --
        Larry Lard
        larrylard@googl email.com
        The address is real, but unread - please reply to the group
        For VB and C# questions - tell us which version

        Comment

        Working...