Groups | Blog | Home
all groups > dotnet drawing api > november 2007 >

dotnet drawing api : Color Equality


Jack Jackson
11/24/2007 3:12:51 PM
On Sat, 24 Nov 2007 17:32:24 -0500, "Nathan Sokalski"
[quoted text, click to view]

If color1.ToArgb() = color2.ToArgb() Then

See
Nathan Sokalski
11/24/2007 5:32:24 PM
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@hotmail.com
http://www.nathansokalski.com/

Bob Powell [MVP]
11/24/2007 11:59:20 PM
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
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.


[quoted text, click to view]
Herfried K. Wagner [MVP]
11/25/2007 12:20:12 AM
"Nathan Sokalski" <njsokalski@hotmail.com> schrieb:
[quoted text, click to view]

See: <URL:http://www.jelovic.com/weblog/e140.htm>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
AddThis Social Bookmark Button