Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Drawing.Color Comparison

Status
Not open for further replies.

woogoo

Programmer
Feb 14, 2004
247
GB
Hi,

I have a custom class (dll) that I use to draw line graphs with by feeding it a collection of (custom GraphData) plotline collections.

As I add a new PlotLine collection to the GraphData collection it is allocated a drawing color from an array of System.Drawing.Color.

When the user clicks a line on the Graph I get the color of the pixel clicked on using GetPixel which returns a System.Drawing.Color.

However, when I try to do an equals on this it never works as the name of the Color returned by GetPixel is in the format of "aarrggbb"

Now, as far as I'm concerned the Name() of the color returned should be identical to the name of the color used to draw the line, but in this instance it's not. If I stop the code as it tries to do a comparison I get "Blue" from my System.Drawing.Color array and "ff0000ff" from my GetPixel() System.Drawing.Color!

Can anyone shed some light on this please.

 
Try using ToString, ToArgb:
Code:
If Col1.ToString = Col2.ToString Then
...
 
Thanks.

This worked, but I still don't understand why they give different results, or is this another Microsoft 'feature'.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top