C# 将uint转换为颜色

C# 将uint转换为颜色,c#,winforms,colors,C#,Winforms,Colors,如何将uint值转换为ARGBSystem.Drawing.Color?我还没有在网上找到这个 我刚刚找到了ARGB touint的方法 我的uint值来自: uint aeroColor; Dwmapi.DwmGetColorizationColor( out aeroColor, out opaque ); uint代表什么?通常,您可以使用以下方法: Color c = Color.FromArgb(intvalue); 使用。但是,这需要的是int,而不是uint。如果您有一个具有相

如何将
uint
值转换为ARGB
System.Drawing.Color
?我还没有在网上找到这个

我刚刚找到了ARGB to
uint
的方法

我的
uint
值来自:

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

uint
代表什么?通常,您可以使用以下方法:

Color c = Color.FromArgb(intvalue);
使用。但是,这需要的是
int
,而不是
uint
。如果您有一个具有相同内存布局的
uint
(与您的情况相同),则以下操作应能正常工作:

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

为什么不呢?那么什么类型的变量返回它呢?@Victor啊,我明白了。由于格式相同(0xAARRGGBB),您可能只需强制转换结果。