|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Color EqualityIs 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. 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. -- Show quoteHide quote-- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. "Nathan Sokalski" <njsokal***@hotmail.com> wrote in message news:%231rOinuLIHA.5400@TK2MSFTNGP04.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 > njsokal***@hotmail.com > http://www.nathansokalski.com/ > On Sat, 24 Nov 2007 17:32:24 -0500, "Nathan Sokalski"
<njsokal***@hotmail.com> wrote: >Is there a way to check whether two Colors are equal? If the Colors have If color1.ToArgb() = color2.ToArgb() Then>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. See <http://msdn2.microsoft.com/en-us/library/system.drawing.color.equals(vs.71).aspx> "Nathan Sokalski" <njsokal***@hotmail.com> schrieb: See: <URL:http://www.jelovic.com/weblog/e140.htm>> 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. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Creating a Web Service (Service, not Client) from WSDL
Trouble with sendkey TAB Reurning Arrays Question about Application Layout Saving an image from a picturebox Editing an indexed PixelFormat Where are use scoped settings stored? Determining the Default Printer Please vote for rendering bug (loss of AlphaChannel) for ico-files! Server Explorer - VS 2005 |
|||||||||||||||||||||||