Color Equality

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    #1

    Color Equality

    Is there a way to check whether two Colors are equal? If the Colors have
    different Name properties, the = operator will return false even if the
    A,R,G, and B properties are equal. I would like to be able to check whether
    two colors are equal based only on the properties that determine what color
    will be displayed. Is there a way to do this without writing my own method?
    Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • Bob Powell [MVP]

    #2
    Re: Color Equality

    Both the Equals method and the = operator check for known colours. The only
    way to check colour equality in a numerical manner is to compare the RGB
    value. Probably the easiest way is to convert to integer and compare those.

    --
    --
    Bob Powell [MVP]
    Visual C#, System.Drawing

    Ramuseco Limited .NET consulting


    Find great Windows Forms articles in Windows Forms Tips and Tricks


    Answer those GDI+ questions with the GDI+ FAQ


    All new articles provide code in C# and VB.NET.
    Subscribe to the RSS feeds provided and never miss a new article.


    "Nathan Sokalski" <njsokalski@hot mail.comwrote in message
    news:%231rOinuL IHA.5400@TK2MSF TNGP04.phx.gbl. ..
    Is there a way to check whether two Colors are equal? If the Colors have
    different Name properties, the = operator will return false even if the
    A,R,G, and B properties are equal. I would like to be able to check
    whether two colors are equal based only on the properties that determine
    what color will be displayed. Is there a way to do this without writing my
    own method? Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。

    >

    Comment

    • Jack Jackson

      #3
      Re: Color Equality

      On Sat, 24 Nov 2007 17:32:24 -0500, "Nathan Sokalski"
      <njsokalski@hot mail.comwrote:
      >Is there a way to check whether two Colors are equal? If the Colors have
      >different Name properties, the = operator will return false even if the
      >A,R,G, and B properties are equal. I would like to be able to check whether
      >two colors are equal based only on the properties that determine what color
      >will be displayed. Is there a way to do this without writing my own method?
      >Thanks.
      If color1.ToArgb() = color2.ToArgb() Then

      See
      <http://msdn2.microsoft .com/en-us/library/system.drawing. color.equals(vs .71).aspx>

      Comment

      Working...