Victor
Victor

Reputation: 14632

Converting uint to Color

How can I convert an uint value to an ARGB System.Drawing.Color? I haven't found this on the internet yet...

I have just found methods for ARGB to uint.

My uint value came from:

uint aeroColor;
Dwmapi.DwmGetColorizationColor( out aeroColor, out opaque );

Upvotes: 3

Views: 7769

Answers (1)

Konrad Rudolph
Konrad Rudolph

Reputation: 546123

What does the uint represent? In general, you can use this:

Color c = Color.FromArgb(intvalue);

Using the appropriate overload. However, this expects an int, not a uint. If you have a uint with the same memory layout (as in your case) then the following should work:

uint aeroColor;
Dwmapi.DwmGetColorizationColor(out aeroColor, out opaque);
Color c = Color.FromArgb((int) aeroColor);

Upvotes: 5

Related Questions