system.Drawing 对比 Maui.Graphics; From.Argb 给出不同的输出
system.Drawing vs Maui.Graphics; From.Argb gives different output
所以我在使用 .NET Maui 时遇到了以下问题。
我想使用 .FromArgb 但在毛伊岛。本来我用的是System.Drawing.Color,但是用的是Maui。 Graphics.Color 给出了不同的结果:
//Color (example color)
int KeyColor = -16777088;
//system.Drawing way:
var forgroundColor = System.Drawing.Color.FromArgb(KeyColor);
//Output: "{Name=ff000080, ARGB=(255, 0, 0, 128)}"
//Maui.Graphics way (I have to use ToString cuz FromArgb needs an string):
var forgroundColorMaui = Microsoft.Maui.Graphics.Color.FromArgb(KeyColor.ToString());
//Output: Red=0, Green=0, Blue=0, Alpha=1
所以我想使用 system.drawing 的输出,然后在 Maui.Graphics 中使用。我不知道为什么输出不同。有人知道吗?谢谢!
看看 documentation for the method:
Color.FromArgb from a string-based hexadecimal value in the form "#AARRGGBB" or "#RRGGBB" or "#ARGB" or "RGB", where each letter corresponds to a hexadecimal digit for the alpha, red, green, and blue channels.
所以我们看到 Maui 版本与 System.Drawing 版本不同,并且需要以不同的方式格式化输入。
所以我在使用 .NET Maui 时遇到了以下问题。 我想使用 .FromArgb 但在毛伊岛。本来我用的是System.Drawing.Color,但是用的是Maui。 Graphics.Color 给出了不同的结果:
//Color (example color)
int KeyColor = -16777088;
//system.Drawing way:
var forgroundColor = System.Drawing.Color.FromArgb(KeyColor);
//Output: "{Name=ff000080, ARGB=(255, 0, 0, 128)}"
//Maui.Graphics way (I have to use ToString cuz FromArgb needs an string):
var forgroundColorMaui = Microsoft.Maui.Graphics.Color.FromArgb(KeyColor.ToString());
//Output: Red=0, Green=0, Blue=0, Alpha=1
所以我想使用 system.drawing 的输出,然后在 Maui.Graphics 中使用。我不知道为什么输出不同。有人知道吗?谢谢!
看看 documentation for the method:
Color.FromArgb from a string-based hexadecimal value in the form "#AARRGGBB" or "#RRGGBB" or "#ARGB" or "RGB", where each letter corresponds to a hexadecimal digit for the alpha, red, green, and blue channels.
所以我们看到 Maui 版本与 System.Drawing 版本不同,并且需要以不同的方式格式化输入。