Skip to content

Commit b40c046

Browse files
Merge branch 'master' into Release
2 parents 6b87f66 + f7959f3 commit b40c046

7 files changed

Lines changed: 130 additions & 58 deletions

File tree

CI/azure-pipelines-build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,17 @@ stages:
110110
buildType: 'current'
111111
artifactName: 'IronDrawingDataTests'
112112
targetPath: '$(Agent.BuildDirectory)/Data'
113+
- task: UseDotNet@2
114+
displayName: 'Install .Netcoreapp3.1 Core sdk'
115+
inputs:
116+
packageType: 'sdk'
117+
version: '3.x'
113118
- task: DotNetCoreCLI@2
114119
displayName: Execute Windows (.NET Core x64) Tests
115120
inputs:
116121
command: 'test'
117122
projects: 'IronDrawingTests/netcoreapp3.1/IronSoftware.Drawing.Common.Tests.dll'
118-
arguments: '-s IronDrawingTests/tests.runsettings --framework "netcoreapp3.1" -v d --blame --blame-hang --blame-crash --blame-hang-timeout 7m --diag:"$(Agent.BuildDirectory)\IronDrawingTests\bin\$(Configuration)\netcoreapp3.1\testhost.log"'
123+
arguments: '-s IronDrawingTests/tests.runsettings --framework "netcoreapp3.1" -v d --blame --diag:"$(Agent.BuildDirectory)\IronDrawingTests\bin\$(Configuration)\netcoreapp3.1\testhost.log"'
119124
testRunTitle: 'Windows (.NET Core) Tests'
120125
publishTestResults: true
121126
# Upload Log files
@@ -139,12 +144,17 @@ stages:
139144
buildType: 'current'
140145
artifactName: 'IronDrawingDataTests'
141146
targetPath: '$(Agent.BuildDirectory)/Data'
147+
- task: UseDotNet@2
148+
displayName: 'Install .Netcoreapp3.1 Core sdk'
149+
inputs:
150+
packageType: 'sdk'
151+
version: '3.x'
142152
- task: DotNetCoreCLI@2
143153
displayName: Execute Windows (.NET Core x86) Tests
144154
inputs:
145155
command: 'test'
146156
projects: 'IronDrawingTests/netcoreapp3.1/IronSoftware.Drawing.Common.Tests.dll'
147-
arguments: '-s IronDrawingTests/tests.x86.runsettings --framework "netcoreapp3.1" -v d --blame --blame-hang --blame-crash --blame-hang-timeout 7m --diag:"$(Agent.BuildDirectory)\IronDrawingTests\bin\$(Configuration)\netcoreapp3.1\testhost.log"'
157+
arguments: '-s IronDrawingTests/tests.x86.runsettings --framework "netcoreapp3.1" -v d --blame --diag:"$(Agent.BuildDirectory)\IronDrawingTests\bin\$(Configuration)\netcoreapp3.1\testhost.log"'
148158
testRunTitle: 'Windows (.NET Core) Tests'
149159
publishTestResults: true
150160
# Upload Log files

IronSoftware.Drawing/IronSoftware.Drawing.Common.Tests/UnitTests/ColorFunctionality.cs

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ public void Create_color_from_RGB()
8585
Assert.Equal(208, color.B);
8686
Assert.Equal("#FF40F4D0", color.ToString());
8787

88+
color = Color.FromArgb(0, 64, 244, 208);
89+
90+
Assert.Equal(0, color.A);
91+
Assert.Equal(64, color.R);
92+
Assert.Equal(244, color.G);
93+
Assert.Equal(208, color.B);
94+
Assert.Equal("#0040F4D0", color.ToString());
95+
8896
}
8997

9098
[FactWithAutomaticDisplayName]
@@ -175,9 +183,10 @@ public void Cast_System_Drawing_Color_to_Color()
175183
Assert.Equal(0, blue.G);
176184
Assert.Equal(255, blue.B);
177185

178-
color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
186+
Int32 iColorCode = Convert.ToInt32("1e81b0", 16);
187+
color = Color.FromArgb(iColorCode);
179188
System.Drawing.Color drawingColor = color;
180-
Assert.Equal(255, drawingColor.A);
189+
Assert.Equal(0, drawingColor.A);
181190
Assert.Equal(30, drawingColor.R);
182191
Assert.Equal(129, drawingColor.G);
183192
Assert.Equal(176, drawingColor.B);
@@ -242,7 +251,7 @@ public void Cast_SKColor_to_Color()
242251

243252
color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
244253
SkiaSharp.SKColor skColor = color;
245-
Assert.Equal(255, skColor.Alpha);
254+
Assert.Equal(0, skColor.Alpha);
246255
Assert.Equal(30, skColor.Red);
247256
Assert.Equal(129, skColor.Green);
248257
Assert.Equal(176, skColor.Blue);
@@ -290,7 +299,7 @@ public void Cast_ImageSharp_Color_to_Color()
290299

291300
color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
292301
SixLabors.ImageSharp.Color imgColor = color;
293-
Assert.Equal("1E81B0FF", imgColor.ToHex());
302+
Assert.Equal("1E81B000", imgColor.ToHex());
294303
}
295304

296305
[FactWithAutomaticDisplayName]
@@ -335,7 +344,7 @@ public void Cast_ImageSharp_Rgba32_to_Color()
335344

336345
color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
337346
SixLabors.ImageSharp.PixelFormats.Rgba32 imgColor = color;
338-
Assert.Equal("1E81B0FF", imgColor.ToHex());
347+
Assert.Equal("1E81B000", imgColor.ToHex());
339348
}
340349

341350
[FactWithAutomaticDisplayName]
@@ -490,7 +499,7 @@ public void Cast_ImageSharp_Rgba64_to_Color()
490499

491500
color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
492501
SixLabors.ImageSharp.PixelFormats.Rgba64 imgColor = color;
493-
Assert.Equal(65535, imgColor.A);
502+
Assert.Equal(0, imgColor.A);
494503
Assert.Equal(7710, imgColor.R);
495504
Assert.Equal(33153, imgColor.G);
496505
Assert.Equal(45232, imgColor.B);
@@ -518,17 +527,17 @@ public void Should_Create_FromName()
518527
color.R.Should().Be(255);
519528
color.G.Should().Be(0);
520529
color.B.Should().Be(0);
521-
530+
522531
color = Color.FromName("green");
523532
color.R.Should().Be(0);
524533
color.G.Should().Be(128);
525534
color.B.Should().Be(0);
526-
535+
527536
color = Color.FromName("blue");
528537
color.R.Should().Be(0);
529538
color.G.Should().Be(0);
530539
color.B.Should().Be(255);
531-
540+
532541
color = Color.FromName("yellow");
533542
color.R.Should().Be(255);
534543
color.G.Should().Be(255);
@@ -553,7 +562,7 @@ public void Should_Create_FromName()
553562
color.R.Should().Be(0);
554563
color.G.Should().Be(0);
555564
color.B.Should().Be(0);
556-
565+
557566
color = Color.FromName("orange");
558567
color.R.Should().Be(255);
559568
color.G.Should().Be(165);
@@ -574,6 +583,21 @@ public void Should_Equal()
574583
(red == null).Should().BeFalse();
575584
}
576585

586+
[Theory]
587+
[InlineData("1e81b0")]
588+
[InlineData("001e81b0")]
589+
[InlineData("FF1e81b0")]
590+
public void From32BitArgb_Should_Equal_Drawing(string colorCode)
591+
{
592+
Int32 iColorCode = Convert.ToInt32(colorCode, 16);
593+
System.Drawing.Color drawingColor = System.Drawing.Color.FromArgb(iColorCode);
594+
Color ironColor = Color.FromArgb(iColorCode);
595+
Assert.Equal(drawingColor.A, ironColor.A);
596+
Assert.Equal(drawingColor.R, ironColor.R);
597+
Assert.Equal(drawingColor.G, ironColor.G);
598+
Assert.Equal(drawingColor.B, ironColor.B);
599+
}
600+
577601
#if !NETFRAMEWORK
578602
[FactWithAutomaticDisplayName]
579603
public void Cast_Maui_from_Color()
@@ -633,7 +657,7 @@ public void Cast_Maui_to_Color()
633657

634658
color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
635659
Microsoft.Maui.Graphics.Color skColor = color;
636-
Assert.Equal(1, skColor.Alpha);
660+
Assert.Equal(0, skColor.Alpha);
637661
Assert.Equal("0.118", skColor.Red.ToString("0.000"));
638662
Assert.Equal("0.506", skColor.Green.ToString("0.000"));
639663
Assert.Equal("0.690", skColor.Blue.ToString("0.000"));

IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace IronSoftware.Drawing
1515
{
1616
/// <summary>
17-
/// <para>A universally compatible Bitmap format for .NET 7, .NET 6, .NET 5, and .NET Core. As well as compatiblity with Windows, NanoServer, IIS, macOS, Mobile, Xamarin, iOS, Android, Google Compute, Azure, AWS, and Linux.</para>
17+
/// <para>A universally compatible Bitmap format for .NET 7, .NET 6, .NET 5, and .NET Core. As well as compatibility with Windows, NanoServer, IIS, macOS, Mobile, Xamarin, iOS, Android, Google Cloud, Azure, AWS, and Linux.</para>
1818
/// <para>Works nicely with popular Image and Bitmap formats such as System.Drawing.Bitmap, SkiaSharp, SixLabors.ImageSharp, Microsoft.Maui.Graphics.</para>
1919
/// <para>Implicit casting means that using this class to input and output Bitmap and image types from public API's gives full compatibility to all image type fully supported by Microsoft.</para>
2020
/// <para>Unlike System.Drawing.Bitmap this bitmap object is self-memory-managing and does not need to be explicitly 'used' or 'disposed'.</para>
@@ -69,6 +69,7 @@ public override int GetHashCode()
6969

7070
/// <summary>
7171
/// A Base64 encoded string representation of the raw image binary data.
72+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/bitmap-to-string/">Code Example</a></para>
7273
/// </summary>
7374
/// <returns>The bitmap data as a Base64 string.</returns>
7475
/// <seealso cref="System.Convert.ToBase64String(byte[])"/>
@@ -88,6 +89,7 @@ public byte[] GetBytes()
8889

8990
/// <summary>
9091
/// The raw image data as a <see cref="System.IO.MemoryStream"/>
92+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/bitmap-to-stream/">Code Example</a></para>
9193
/// </summary>
9294
/// <returns><see cref="System.IO.MemoryStream"/></returns>
9395
public System.IO.MemoryStream GetStream()
@@ -97,6 +99,7 @@ public System.IO.MemoryStream GetStream()
9799

98100
/// <summary>
99101
/// Creates an exact duplicate <see cref="AnyBitmap"/>
102+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/clone-anybitmap/">Code Example</a></para>
100103
/// </summary>
101104
/// <returns></returns>
102105
public AnyBitmap Clone()
@@ -106,6 +109,7 @@ public AnyBitmap Clone()
106109

107110
/// <summary>
108111
/// Creates an exact duplicate <see cref="AnyBitmap"/> of the cropped area.
112+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/clone-anybitmap/">Code Example</a></para>
109113
/// </summary>
110114
/// <param name="Rectangle">Defines the portion of this <see cref="AnyBitmap"/> to copy.</param>
111115
/// <returns></returns>
@@ -138,6 +142,7 @@ public byte[] ExportBytes(ImageFormat Format = ImageFormat.Default, int Lossy =
138142
/// <summary>
139143
/// Exports the Bitmap as a file encoded in the <see cref="ImageFormat"/> of your choice.
140144
/// <para>Add SkiaSharp, System.Drawing.Common, or SixLabors.ImageSharp to your project to enable the encoding feature.</para>
145+
/// <para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/export-anybitmap/">Code Example</a></para>
141146
/// </summary>
142147
/// <param name="File">A fully qualified file path.</param>
143148
/// <param name="Format">An image encoding format.</param>
@@ -155,6 +160,7 @@ public void ExportFile(string File, ImageFormat Format = ImageFormat.Default, in
155160
/// <summary>
156161
/// Exports the Bitmap as a <see cref="MemoryStream"/> encoded in the <see cref="ImageFormat"/> of your choice.
157162
/// <para>Add SkiaSharp, System.Drawing.Common, or SixLabors.ImageSharp to your project to enable the encoding feature.</para>
163+
/// <para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/bitmap-to-stream/">Code Example</a></para>
158164
/// </summary>
159165
/// <param name="Format">An image encoding format.</param>
160166
/// <param name="Lossy">JPEG and WebP encoding quality (ignored for all other values of <see cref="ImageFormat"/>). Higher values return larger file sizes. 0 is lowest quality, 100 is highest.</param>
@@ -486,6 +492,7 @@ public static AnyBitmap FromUri(Uri Uri)
486492

487493
/// <summary>
488494
/// Gets colors depth, in number of bits per pixel.
495+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/get-color-depth/">Code Example</a></para>
489496
/// </summary>
490497
public int BitsPerPixel
491498
{
@@ -496,7 +503,8 @@ public int BitsPerPixel
496503
}
497504

498505
/// <summary>
499-
/// Returns the number of frames in our loaded Image. Each “frame” is a page of an image such as Tiff or Gif. All other image formats return 1.
506+
/// Returns the number of frames in our loaded Image. Each “frame” is a page of an image such as Tiff or Gif. All other image formats return 1.
507+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/get-number-of-frames-in-anybitmap/">Code Example</a></para>
500508
/// </summary>
501509
/// <seealso cref="GetAllFrames" />
502510
public int FrameCount
@@ -509,6 +517,7 @@ public int FrameCount
509517

510518
/// <summary>
511519
/// Returns all of the cloned frames in our loaded Image. Each "frame" is a page of an image such as Tiff or Gif. All other image formats return an IEnumerable of length 1.
520+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/get-frame-from-anybitmap/">Code Example</a></para>
512521
/// </summary>
513522
/// <seealso cref="FrameCount" />
514523
/// <seealso cref="System.Linq" />

IronSoftware.Drawing/IronSoftware.Drawing.Common/Color.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public partial class Color
3838

3939
/// <summary>
4040
/// Construct a new <see cref="Color"/>.
41+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/create-color/">Code Example</a></para>
4142
/// </summary>
4243
/// <param name="colorcode">The hexadecimal representation of the combined color components arranged in rgb, argb, rrggbb, or aarrggbb format to match web syntax.</param>
4344
public Color(string colorcode)
@@ -73,6 +74,7 @@ public Color(string colorcode)
7374

7475
/// <summary>
7576
/// Construct a new <see cref="Color"/>.
77+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/create-color/">Code Example</a></para>
7678
/// </summary>
7779
/// <param name="alpha">The alpha component. Valid values are 0 through 255.</param>
7880
/// <param name="red">The red component. Valid values are 0 through 255.</param>
@@ -88,6 +90,7 @@ public Color(int alpha, int red, int green, int blue)
8890

8991
/// <summary>
9092
/// Construct a new <see cref="Color"/>.
93+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/create-color/">Code Example</a></para>
9194
/// </summary>
9295
/// <param name="red">The red component. Valid values are 0 through 255.</param>
9396
/// <param name="green">The green component. Valid values are 0 through 255.</param>
@@ -876,7 +879,12 @@ public static Color FromArgb(int alpha, Color baseColor)
876879
/// <seealso cref="FromArgb(int, int, int, int)"/>
877880
public static Color FromArgb(int argb)
878881
{
879-
return new Color(argb.ToString("X"));
882+
string colorCode = argb.ToString("X");
883+
if (colorCode.Length == 6)
884+
{
885+
colorCode = "00" + colorCode;
886+
}
887+
return new Color(colorCode);
880888
}
881889

882890
/// <summary>
@@ -900,7 +908,7 @@ public static Color FromName(string name)
900908
/// <returns></returns>
901909
public override string ToString()
902910
{
903-
return $"#{this.A:X}{this.R:X}{this.G:X}{this.B:X}";
911+
return $"#{this.A:X2}{this.R:X2}{this.G:X2}{this.B:X2}";
904912
}
905913

906914
/// <summary>
@@ -915,6 +923,7 @@ public double GetLuminance()
915923

916924
/// <summary>
917925
/// Gets the 32-bit ARGB value of this <see cref="Color"/> structure.
926+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/convert-color-to-32-bit-argb-value/">Code Example</a></para>
918927
/// </summary>
919928
/// <returns>The 32-bit ARGB value of this <see cref="Color"/>.</returns>
920929
public int ToArgb()

IronSoftware.Drawing/IronSoftware.Drawing.Common/CropRectangle.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public MeasurementUnits Units
6060

6161
/// <summary>
6262
/// Convert this crop rectangle to the specified units of measurement using the specified DPI
63+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/convert-measurement-unit-of-croprectangle/">Code Example</a></para>
6364
/// </summary>
6465
/// <param name="units">Unit of measurement</param>
6566
/// <param name="dpi">DPI (Dots per inch) for conversion</param>

IronSoftware.Drawing/IronSoftware.Drawing.Common/Font.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public bool Strikeout
6969

7070
/// <summary>
7171
/// Initializes a new Font that uses the specified existing FamilyName.
72+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/create-and-cast-font/">Code Example</a></para>
7273
/// </summary>
7374
/// <param name="FamilyName">The FontFamily of the new Font.</param>
7475
public Font(string FamilyName)
@@ -78,6 +79,7 @@ public Font(string FamilyName)
7879

7980
/// <summary>
8081
/// Initializes a new Font that uses the specified existing FamilyName and FontStyle enumeration.
82+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/create-and-cast-font/">Code Example</a></para>
8183
/// </summary>
8284
/// <param name="FamilyName">The FontFamily of the new Font.</param>
8385
/// <param name="Style">The FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator.</param>
@@ -89,6 +91,7 @@ public Font(string FamilyName, FontStyle Style)
8991

9092
/// <summary>
9193
/// Initializes a new Font that uses the specified existing FamilyName, FontStyle enumeration, FontWeight, Bold, Italic and Size.
94+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/create-and-cast-font/">Code Example</a></para>
9295
/// </summary>
9396
/// <param name="FamilyName">The FontFamily of the new Font.</param>
9497
/// <param name="Style">The FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator.</param>
@@ -102,6 +105,7 @@ public Font(string FamilyName, FontStyle Style, float Size)
102105

103106
/// <summary>
104107
/// Initializes a new Font that uses the specified existing FamilyName, FontWeight, Bold, Italic and Size.
108+
/// <br/><para><b>Further Documentation:</b><br/><a href="https://ironsoftware.com/open-source/csharp/drawing/examples/create-and-cast-font/">Code Example</a></para>
105109
/// </summary>
106110
/// <param name="FamilyName">The FontFamily of the new Font.</param>
107111
/// <param name="Size">The em-size of the new font in the units specified by the unit parameter.</param>

0 commit comments

Comments
 (0)