So I am using .NET Maui and came across the following problem. I want to use .FromArgb but in Maui. Originally I was using System.Drawing.Color, but using Maui. Graphics.Color gives a different result:
//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
So I want to use the output from system.drawing but then in the Maui.Graphics. I dont know why the outputs are different. Anyone got an idea? Thanks you!
CodePudding user response:
Take a look at the 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.
So we see the Maui version is not the same as the System.Drawing version and expects the input formatted in a different way.