iron-software / IronSoftware.System.Drawing

An open-source System.Drawing.Common replacement for .NET 5 and above on all platforms. Bringing together System.Drawing, Maui, and ImageSharp's Bitmap, Image, Font, and Shape types via an agnostic free NuGet package.
Other
114 stars 18 forks source link

Fixes Color.ToString() return incorrect #35

Closed mee-ironsoftware closed 1 year ago

mee-ironsoftware commented 1 year ago

Some value will return 1 digit instead of 2.

Eg.

Color color = Color.FromArgb(0, 64, 244, 208);
color.ToString(); // Should be #0040F4D0
mee-ironsoftware commented 1 year ago

return new Color(argb.ToString("X")); should be return new Color(argb.ToString("X2")); too?

Don't need X2 format for converting 32-bit ARGB into color code. But found another bug on IronSoftware.Drawing.Color.FromArgb with RGB code to 32-Bit ARGB, Alpha should be 0 instead of 255.

Eg.

Int32 iColorCode = Convert.ToInt32("1e81b0", 16);
// This will produce A=0, R=30, G=129, and B=176
System.Drawing.Color drawingColor = System.Drawing.Color.FromArgb(iColorCode);
// For IronDrawing should produce the same
// Before fixes this produce A=255, R=30, G=129, and B=176
IronSoftware.Drawing.Color ironColor = IronSoftware.Drawing.Color.FromArgb(iColorCode);