Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CI/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ stages:
inputs:
workingDirectory: 'bin\$(Configuration)\netstandard2.0'
script: '$(Build.SourcesDirectory)\NuGet\signtool.exe sign /v /d IronDrawing /f $(Agent.TempDirectory)/ironcert.pfx /p ironcert /t http://timestamp.digicert.com /fd SHA256 "IronSoftware.Drawing.Common.dll"'
- task: NuGetToolInstaller@1
inputs:
versionSpec: 6.2.1
- task: NuGetCommand@2
displayName: 'Build DrawingLibraries NuGet Package'
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,5 +379,178 @@ public void Cast_ImageSharp_Rgb24_to_Color()
Assert.Equal(129, imgColor.G);
Assert.Equal(176, imgColor.B);
}

[FactWithAutomaticDisplayName]
public void Cast_ImageSharp_Rgb48_from_Color()
{
SixLabors.ImageSharp.PixelFormats.Rgb48 imgColor = new SixLabors.ImageSharp.PixelFormats.Rgb48(255, 0, 0);
Color red = imgColor;
Assert.Equal(255, red.R);
Assert.Equal(0, red.G);
Assert.Equal(0, red.B);

imgColor = new SixLabors.ImageSharp.PixelFormats.Rgb48(0, 255, 0);
Color green = imgColor;
Assert.Equal(255, green.A);
Assert.Equal(0, green.R);
Assert.Equal(255, green.G);
Assert.Equal(0, green.B);

imgColor = new SixLabors.ImageSharp.PixelFormats.Rgb48(0, 0, 255);
Color blue = imgColor;
Assert.Equal(0, blue.R);
Assert.Equal(0, blue.G);
Assert.Equal(255, blue.B);
}

[FactWithAutomaticDisplayName]
public void Cast_ImageSharp_Rgb48_to_Color()
{
Color color = Color.Red;
SixLabors.ImageSharp.PixelFormats.Rgb48 red = color;
Assert.Equal(255, red.R);
Assert.Equal(0, red.G);
Assert.Equal(0, red.B);

color = new Color(0, 255, 0);
SixLabors.ImageSharp.PixelFormats.Rgb48 green = color;
Assert.Equal(0, green.R);
Assert.Equal(255, green.G);
Assert.Equal(0, green.B);

color = new Color("#0000FF");
SixLabors.ImageSharp.PixelFormats.Rgb48 blue = color;
Assert.Equal(0, blue.R);
Assert.Equal(0, blue.G);
Assert.Equal(255, blue.B);

color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
SixLabors.ImageSharp.PixelFormats.Rgb48 imgColor = color;
Assert.Equal(30, imgColor.R);
Assert.Equal(129, imgColor.G);
Assert.Equal(176, imgColor.B);
}

[FactWithAutomaticDisplayName]
public void Cast_ImageSharp_Rgba64_from_Color()
{
SixLabors.ImageSharp.PixelFormats.Rgba64 imgColor = SixLabors.ImageSharp.Color.Red;
Color red = imgColor;
Assert.Equal(255, red.R);
Assert.Equal(0, red.G);
Assert.Equal(0, red.B);

imgColor = new SixLabors.ImageSharp.PixelFormats.Rgba64(0, 255, 0, 255);
Color green = imgColor;
Assert.Equal(255, green.A);
Assert.Equal(0, green.R);
Assert.Equal(255, green.G);
Assert.Equal(0, green.B);

imgColor = new SixLabors.ImageSharp.PixelFormats.Rgba64(0, 0, 255, 255);
Color blue = imgColor;
Assert.Equal(255, green.A);
Assert.Equal(0, blue.R);
Assert.Equal(0, blue.G);
Assert.Equal(255, blue.B);
}

[FactWithAutomaticDisplayName]
public void Cast_ImageSharp_Rgba64_to_Color()
{
Color color = Color.Red;
SixLabors.ImageSharp.PixelFormats.Rgba64 red = color;
Assert.Equal(65535, red.A);
Assert.Equal(65535, red.R);
Assert.Equal(0, red.G);
Assert.Equal(0, red.B);

color = new Color(0, 255, 0);
SixLabors.ImageSharp.PixelFormats.Rgba64 green = color;
Assert.Equal(65535, green.A);
Assert.Equal(0, green.R);
Assert.Equal(65535, green.G);
Assert.Equal(0, green.B);

color = new Color("#0000FF");
SixLabors.ImageSharp.PixelFormats.Rgba64 blue = color;
Assert.Equal(65535, blue.A);
Assert.Equal(0, blue.R);
Assert.Equal(0, blue.G);
Assert.Equal(65535, blue.B);

color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
SixLabors.ImageSharp.PixelFormats.Rgba64 imgColor = color;
Assert.Equal(65535, imgColor.A);
Assert.Equal(7710, imgColor.R);
Assert.Equal(33153, imgColor.G);
Assert.Equal(45232, imgColor.B);
}

#if !NET472
[FactWithAutomaticDisplayName]
public void Cast_Maui_from_Color()
{
Microsoft.Maui.Graphics.Color mColor = Microsoft.Maui.Graphics.Colors.Red;
Color red = mColor;
Assert.Equal(255, red.A);
Assert.Equal(255, red.R);
Assert.Equal(0, red.G);
Assert.Equal(0, red.B);

mColor = new Microsoft.Maui.Graphics.Color(0, 255, 0, 255);
Color green = mColor;
Assert.Equal(255, green.A);
Assert.Equal(0, green.R);
Assert.Equal(255, green.G);
Assert.Equal(0, green.B);

mColor = new Microsoft.Maui.Graphics.Color(0, 0, 255);
Color blue = mColor;
Assert.Equal(255, blue.A);
Assert.Equal(0, blue.R);
Assert.Equal(0, blue.G);
Assert.Equal(255, blue.B);

mColor = Microsoft.Maui.Graphics.Color.FromArgb("ff1e81b0");
Color color = mColor;
Assert.Equal(255, color.A);
Assert.Equal(30, color.R);
Assert.Equal(129, color.G);
Assert.Equal(176, color.B);
}

[FactWithAutomaticDisplayName]
public void Cast_Maui_to_Color()
{
Color color = Color.Red;
Microsoft.Maui.Graphics.Color red = color;
Assert.Equal(1, red.Alpha);
Assert.Equal(1, red.Red);
Assert.Equal(0, red.Green);
Assert.Equal(0, red.Blue);

color = new Color(0, 255, 0);
Microsoft.Maui.Graphics.Color green = color;
Assert.Equal(1, green.Alpha);
Assert.Equal(0, green.Red);
Assert.Equal(1, green.Green);
Assert.Equal(0, green.Blue);

color = new Color("#0000FF");
Microsoft.Maui.Graphics.Color blue = color;
Assert.Equal(1, blue.Alpha);
Assert.Equal(0, blue.Red);
Assert.Equal(0, blue.Green);
Assert.Equal(1, blue.Blue);

color = Color.FromArgb(Convert.ToInt32("1e81b0", 16));
Microsoft.Maui.Graphics.Color skColor = color;
Assert.Equal(1, skColor.Alpha);
Assert.Equal("0.118", skColor.Red.ToString("0.000"));
Assert.Equal("0.506", skColor.Green.ToString("0.000"));
Assert.Equal("0.690", skColor.Blue.ToString("0.000"));
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,40 @@ public void CastImageSharp_Rectangle_from_CropRectangle()
Assert.Equal(5, rectangle.Y);
}

[FactWithAutomaticDisplayName]
public void CastImageSharp_RectangleF_to_CropRectangle()
{
SixLabors.ImageSharp.RectangleF rectangle = new SixLabors.ImageSharp.RectangleF(10, 10, 150, 150);
CropRectangle cropRectangle = rectangle;
Assert.NotNull(cropRectangle);
Assert.Equal(150, cropRectangle.Width);
Assert.Equal(150, cropRectangle.Height);
Assert.Equal(10, cropRectangle.X);
Assert.Equal(10, cropRectangle.Y);

rectangle = new SixLabors.ImageSharp.Rectangle(new SixLabors.ImageSharp.Point(15, 15), new SixLabors.ImageSharp.Size(75, 75));
cropRectangle = rectangle;
Assert.NotNull(cropRectangle);
Assert.Equal(75, cropRectangle.Width);
Assert.Equal(75, cropRectangle.Height);
Assert.Equal(15, cropRectangle.X);
Assert.Equal(15, cropRectangle.Y);
}

[FactWithAutomaticDisplayName]
public void CastImageSharp_RectangleF_from_CropRectangle()
{
CropRectangle cropRectangle = new CropRectangle(5, 5, 50, 50);

SixLabors.ImageSharp.RectangleF rectangle = cropRectangle;

Assert.NotNull(cropRectangle);
Assert.Equal(50, rectangle.Width);
Assert.Equal(50, rectangle.Height);
Assert.Equal(5, rectangle.X);
Assert.Equal(5, rectangle.Y);
}

[FactWithAutomaticDisplayName]
public void CastSKRect_to_CropRectangle()
{
Expand Down Expand Up @@ -211,5 +245,83 @@ public void CastSKRectI_from_CropRectangle()
Assert.Equal(215, rect.Right);
Assert.Equal(215, rect.Bottom);
}

#if !NET472

[FactWithAutomaticDisplayName]
public void CastMaui_Rect_to_CropRectangle()
{
Microsoft.Maui.Graphics.Rect rect = new Microsoft.Maui.Graphics.Rect(50, 100, 150, 25);
CropRectangle cropRectangle = rect;
Assert.NotNull(cropRectangle);
Assert.Equal(150, cropRectangle.Width);
Assert.Equal(25, cropRectangle.Height);
Assert.Equal(50, cropRectangle.X);
Assert.Equal(100, cropRectangle.Y);

rect = new Microsoft.Maui.Graphics.Rect(150, 25, 50, 100);
cropRectangle = rect;
Assert.NotNull(cropRectangle);
Assert.Equal(50, cropRectangle.Width);
Assert.Equal(100, cropRectangle.Height);
Assert.Equal(150, cropRectangle.X);
Assert.Equal(25, cropRectangle.Y);
}

[FactWithAutomaticDisplayName]
public void CastMaui_Rect_from_CropRectangle()
{
CropRectangle cropRectangle = new CropRectangle(50, 25, 50, 50);
Microsoft.Maui.Graphics.Rect rect = cropRectangle;
Assert.Equal(50, rect.Left);
Assert.Equal(25, rect.Top);
Assert.Equal(100, rect.Right);
Assert.Equal(75, rect.Bottom);

cropRectangle = new CropRectangle(15, 15, 200, 200);
rect = cropRectangle;
Assert.Equal(15, rect.Left);
Assert.Equal(15, rect.Top);
Assert.Equal(215, rect.Right);
Assert.Equal(215, rect.Bottom);
}
[FactWithAutomaticDisplayName]
public void CastMaui_RectF_to_CropRectangle()
{
Microsoft.Maui.Graphics.RectF rect = new Microsoft.Maui.Graphics.RectF(50, 100, 150, 25);
CropRectangle cropRectangle = rect;
Assert.NotNull(cropRectangle);
Assert.Equal(150, cropRectangle.Width);
Assert.Equal(25, cropRectangle.Height);
Assert.Equal(50, cropRectangle.X);
Assert.Equal(100, cropRectangle.Y);

rect = new Microsoft.Maui.Graphics.RectF(150, 25, 50, 100);
cropRectangle = rect;
Assert.NotNull(cropRectangle);
Assert.Equal(50, cropRectangle.Width);
Assert.Equal(100, cropRectangle.Height);
Assert.Equal(150, cropRectangle.X);
Assert.Equal(25, cropRectangle.Y);
}

[FactWithAutomaticDisplayName]
public void CastMaui_RectF_from_CropRectangle()
{
CropRectangle cropRectangle = new CropRectangle(50, 25, 50, 50);
Microsoft.Maui.Graphics.RectF rect = cropRectangle;
Assert.Equal(50, rect.Left);
Assert.Equal(25, rect.Top);
Assert.Equal(100, rect.Right);
Assert.Equal(75, rect.Bottom);

cropRectangle = new CropRectangle(15, 15, 200, 200);
rect = cropRectangle;
Assert.Equal(15, rect.Left);
Assert.Equal(15, rect.Top);
Assert.Equal(215, rect.Right);
Assert.Equal(215, rect.Bottom);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,80 @@ public void CastSixLaborsFont_from_Font()
sixLaborsFont.IsItalic.Should().BeTrue();
}
}

#if !NET472


[FactWithAutomaticDisplayName]
public void CastMauiFont_to_Font()
{

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Microsoft.Maui.Graphics.Font mFont = new Microsoft.Maui.Graphics.Font("Liberation Mono");
Font font = mFont;
font.FamilyName.Should().Be("Liberation Mono");
font.Style.Should().Be(FontStyle.Regular);
font.Bold.Should().BeFalse();
font.Italic.Should().BeFalse();

mFont = new Microsoft.Maui.Graphics.Font("Liberation Serif", 800, Microsoft.Maui.Graphics.FontStyleType.Italic);
font = mFont;
font.FamilyName.Should().Be("Liberation Serif");
font.Style.Should().Be(FontStyle.Bold | FontStyle.Italic);
font.Bold.Should().BeTrue();
font.Italic.Should().BeTrue();
}
else
{
Microsoft.Maui.Graphics.Font mFont = new Microsoft.Maui.Graphics.Font("Courier New");
Font font = mFont;
font.FamilyName.Should().Be("Courier New");
font.Style.Should().Be(FontStyle.Regular);
font.Bold.Should().BeFalse();
font.Italic.Should().BeFalse();

mFont = new Microsoft.Maui.Graphics.Font("Times New Roman", 800, Microsoft.Maui.Graphics.FontStyleType.Italic);
font = mFont;
font.FamilyName.Should().Be("Times New Roman");
font.Style.Should().Be(FontStyle.Bold | FontStyle.Italic);
font.Bold.Should().BeTrue();
font.Italic.Should().BeTrue();
}
}

[FactWithAutomaticDisplayName]
public void CastMauiFont_from_Font()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Font font = new Font("Liberation Mono", 30);
Microsoft.Maui.Graphics.Font mFont = font;
mFont.Name.Should().Be("Liberation Mono");
mFont.Weight.Should().Be(400);
mFont.StyleType.Should().Be(Microsoft.Maui.Graphics.FontStyleType.Normal);

font = new Font("Liberation Serif", FontStyle.Bold | FontStyle.Italic, 20);
mFont = font;
mFont.Name.Should().Be("Liberation Serif");
mFont.Weight.Should().Be(700);
mFont.StyleType.Should().Be(Microsoft.Maui.Graphics.FontStyleType.Italic);
}
else
{
Font font = new Font("Courier New", 30);
Microsoft.Maui.Graphics.Font mFont = font;
mFont.Name.Should().Be("Courier New");
mFont.Weight.Should().Be(400);
mFont.StyleType.Should().Be(Microsoft.Maui.Graphics.FontStyleType.Normal);

font = new Font("Times New Roman", FontStyle.Bold | FontStyle.Italic, 20);
mFont = font;
mFont.Name.Should().Be("Times New Roman");
mFont.Weight.Should().Be(700);
mFont.StyleType.Should().Be(Microsoft.Maui.Graphics.FontStyleType.Italic);
}
}
#endif
}
}
Loading