CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    Salt Lake City, Utah
    Posts
    217

    URGENT:: opposite color

    I try to find out how to calculate the opposite color. For example, if white is given, black should be the output color.


  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,721

    Re: URGENT:: opposite color



    There are probably numerous ways to define opposite color, but
    here is one way ...



    COLORREF original_color = RGB(100,300,50); // whatever you want it

    //
    // determine the opposite color
    //

    int opp_red = 255 - GetRValue(original_color);
    int opp_green = 255 - GetGValue(original_color);
    int opp_blue = 255 - GetBValue(original_color);

    COLORREF oposite_color = RGB(opp_red,opp_green,opp_blue);









  3. #3
    Join Date
    Aug 1999
    Location
    Salt Lake City, Utah
    Posts
    217

    Re: URGENT:: opposite color

    In that way, RGB(128, 128, 128) will return RGB(127,127,127). That is almost same color instead of opposite color. Do you have another way?


  4. #4
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,721

    Re: URGENT:: opposite color

    Not off hand ... I am not sure what the opposite of medium gray would even be. The opposite of light gray is dark gray. What do you think the opposite of medium gray should be ? I'll let you know if I can think of anything else.


  5. #5
    Join Date
    Aug 2000
    Posts
    393

    Re: URGENT:: opposite color

    The opposite of medium gray (128,128,128) is medium gray (127,127,127). Try it in MS Paint. It's analogous to finding the opposite of zero. Nothing is darker than black so it can't be the center point of inversion. The center point is medium grey (128,128,128).

    mr. blonde


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured