c# - How to check if two System.Drawing.Color structures represent the same color in 16 bit color depth? -


How can I check that the two systems Drawing The color structure represents the same color in depth of 16-bit color (or usually the screen's value, the primary screen. BeatsPixel)?

Suppose I set the form. Transparency Voice1 (color type), I want to know that when the user chooses a new background color for the form (value 2), I do not set completely transparent.

On the 32-bit color depth screen I compare two values:

If (value1 == value2)

However, this 16bit color Depth does not work on the screen, because the more color values ​​for value 2 will represent the same real 16bit color as value 1, because I found the hard way.

Try the following code:

  zero myTestMethod () {TransparencyKey = Color.FromArgb (128, 128, 64); BackColor = Color.FromArgb (128, 128, 71); Byte TR = Convert R (Transparency R); Byte TG = Convertji (Transparency.G); Byte TB = Convertib (Transparency.b); Byte BR = Convert R (Backcorer.); Byte BG = Convertiji (backcolor.g); Byte Bb = convert B (backcolor.b); If (TR == BR & TG == BG & TB == BB) {message box. Show ("par:" + + +, "+ + + + +", "+ + + TB + \" \ N "+ BR +", "+ BG +", "+ BB");} Else {MessageBox.Show ("Not equal:" + + TR + "," + TG + "," + TB + "\ r \ n" + BR + "," + BG + "," + BB) "}} Byte ConvertR (Byte Colorbet) {Return (Byte) (((Double) Colorbit / 256.0) * 32.0) Byte ConvertG (Byte Colorabette) {Return (Byte) (((Double (Double) Colorbet / 256.0) * 64.0);} Byte Convertby (Byte Colorabette) {Return (Byte) (((Double () Colorbet / 256.0) * 32.0);}  

Stupid with TransparancyKey and BackColor to see if it's your L A works. Did it for me and yes, I know that it is bloated and ugly code, it is just an example of course.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -