How to check if two System.Drawing.Color structures represent the same color in 16 bit color depth?
- by David
How can I check if two System.Drawing.Color structures represent the same color in 16 bit color depth (or generally based on the value of Screen.PrimaryScreen.BitsPerPixel)?
Let's say I set Form.TransparencyKey to Value1 (of Color type), I want to check that when the user selects a new background color for the form (Value2), I don't set the entire form transparent.
On 32bit color depth screens I simply compare the two values:
if (Value1 == Value2)
However, this does not work on 16bit color depth screens, as more Color values for the Value2 would represent the same actual 16bit color as Value1, as I found out the hard way.