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
13 changes: 0 additions & 13 deletions CI/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,3 @@ stages:
publishSymbols: true
symbolServerType: TeamServices
detailedLog: true
- task: GitHubRelease@1
inputs:
isPreRelease: true
gitHubConnection: 'ironsoftwarebuild'
repositoryName: 'iron-software/IronSoftware.System.Drawing'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
tag: '$(NuGetVersion)'
title: 'IronSoftware.System.Drawing v$(NuGetVersion)'
releaseNotesSource: 'inline'
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -268,6 +271,16 @@ public void Clone_AnyBitmap()
clonedAnyBitmap.SaveAs("result.png");

AssertImageAreEqual("expected.png", "result.png", true);


using Image image = anyBitmap;
image.Mutate(img => img.Crop(new Rectangle(0, 0, 100, 100)));
AnyBitmap clonedWithRect = anyBitmap.Clone(new CropRectangle(0, 0, 100, 100));

image.SaveAsPng("expected.png");
clonedWithRect.SaveAs("result.png");

AssertImageAreEqual("expected.png", "result.png", true);
}

[FactWithAutomaticDisplayName]
Expand Down Expand Up @@ -361,6 +374,153 @@ public void CastSixLabors_from_AnyBitmap()
AssertImageAreEqual("expected.bmp", "result.bmp", true);
}

[FactWithAutomaticDisplayName]
public void Load_Tiff_Image()
{
AnyBitmap anyBitmap = AnyBitmap.FromFile(GetRelativeFilePath("IRON-274-39065.tif"));
Assert.Equal(2, anyBitmap.FrameCount);

AnyBitmap multiPage = AnyBitmap.FromFile(GetRelativeFilePath("animated_qr.gif"));
Assert.Equal(4, multiPage.FrameCount);
Assert.Equal(4, multiPage.GetAllFrames.Count());
multiPage.GetAllFrames.First().SaveAs("first.png");
multiPage.GetAllFrames.Last().SaveAs("last.png");
AssertImageAreEqual(GetRelativeFilePath("first-animated-qr.png"), "first.png");
AssertImageAreEqual(GetRelativeFilePath("last-animated-qr.png"), "last.png");

byte[] bytes = File.ReadAllBytes(GetRelativeFilePath("IRON-274-39065.tif"));
anyBitmap = AnyBitmap.FromBytes(bytes);
Assert.Equal(2, anyBitmap.FrameCount);

byte[] multiPageBytes = File.ReadAllBytes(GetRelativeFilePath("animated_qr.gif"));
multiPage = AnyBitmap.FromBytes(multiPageBytes);
Assert.Equal(4, multiPage.FrameCount);
Assert.Equal(4, multiPage.GetAllFrames.Count());
multiPage.GetAllFrames.First().SaveAs("first.png");
multiPage.GetAllFrames.Last().SaveAs("last.png");
AssertImageAreEqual(GetRelativeFilePath("first-animated-qr.png"), "first.png");
AssertImageAreEqual(GetRelativeFilePath("last-animated-qr.png"), "last.png");
}

[FactWithAutomaticDisplayName]
public void Try_UnLoad_Tiff_Image()
{
AnyBitmap anyBitmap = AnyBitmap.FromFile(GetRelativeFilePath("multiframe.tiff"));
Assert.Equal(2, anyBitmap.FrameCount);
}

[FactWithAutomaticDisplayName]
public void Create_Multi_page_Tiff()
{
List<AnyBitmap> bitmaps = new List<AnyBitmap>()
{
AnyBitmap.FromFile(GetRelativeFilePath("first-animated-qr.png")),
AnyBitmap.FromFile(GetRelativeFilePath("last-animated-qr.png"))
};

AnyBitmap anyBitmap = AnyBitmap.CreateMultiFrameTiff(bitmaps);
Assert.Equal(2, anyBitmap.FrameCount);
Assert.Equal(2, anyBitmap.GetAllFrames.Count());
anyBitmap.GetAllFrames.ElementAt(0).SaveAs("first.png");
anyBitmap.GetAllFrames.ElementAt(1).SaveAs("last.png");
AssertImageAreEqual(GetRelativeFilePath("first-animated-qr.png"), "first.png");
AssertImageAreEqual(GetRelativeFilePath("last-animated-qr.png"), "last.png");
}

[FactWithAutomaticDisplayName]
public void Create_Multi_page_Tiff_Paths()
{
List<string> imagePaths = new List<string>()
{
GetRelativeFilePath("first-animated-qr.png"),
GetRelativeFilePath("last-animated-qr.png")
};

AnyBitmap anyBitmap = AnyBitmap.CreateMultiFrameTiff(imagePaths);
Assert.Equal(2, anyBitmap.FrameCount);
Assert.Equal(2, anyBitmap.GetAllFrames.Count());
anyBitmap.GetAllFrames.ElementAt(0).SaveAs("first.png");
anyBitmap.GetAllFrames.ElementAt(1).SaveAs("last.png");
AssertImageAreEqual(GetRelativeFilePath("first-animated-qr.png"), "first.png");
AssertImageAreEqual(GetRelativeFilePath("last-animated-qr.png"), "last.png");
}

[FactWithAutomaticDisplayName]
public void Create_Multi_page_Gif()
{
List<AnyBitmap> bitmaps = new List<AnyBitmap>()
{
AnyBitmap.FromFile(GetRelativeFilePath("first-animated-qr.png")),
AnyBitmap.FromFile(GetRelativeFilePath("mountainclimbers.jpg"))
};

AnyBitmap anyBitmap = AnyBitmap.CreateMultiFrameGif(bitmaps);
Assert.Equal(2, anyBitmap.FrameCount);
Assert.Equal(2, anyBitmap.GetAllFrames.Count());
anyBitmap.GetAllFrames.ElementAt(0).SaveAs("first.png");
Image first = Image.Load(GetRelativeFilePath("first-animated-qr.png"));
first.Mutate(img => img.Resize(new ResizeOptions
{
Size = new SixLabors.ImageSharp.Size(anyBitmap.GetAllFrames.ElementAt(0).Width, anyBitmap.GetAllFrames.ElementAt(0).Height),
Mode = SixLabors.ImageSharp.Processing.ResizeMode.BoxPad
}));
first.Save("first-expected.jpg");
AssertImageAreEqual("first-expected.jpg", "first.png", true);

anyBitmap.GetAllFrames.ElementAt(1).SaveAs("last.png");
Image last = Image.Load(GetRelativeFilePath("mountainclimbers.jpg"));
last.Mutate(img => img.Resize(new ResizeOptions
{
Size = new SixLabors.ImageSharp.Size(anyBitmap.GetAllFrames.ElementAt(1).Width, anyBitmap.GetAllFrames.ElementAt(1).Height),
Mode = SixLabors.ImageSharp.Processing.ResizeMode.BoxPad
}));
last.Save("last-expected.jpg");
AssertImageAreEqual("last-expected.jpg", "last.png", true);
}

[FactWithAutomaticDisplayName]
public void Create_Multi_page_Gif_paths()
{
List<string> imagePaths = new List<string>()
{
GetRelativeFilePath("first-animated-qr.png"),
GetRelativeFilePath("mountainclimbers.jpg")
};

AnyBitmap anyBitmap = AnyBitmap.CreateMultiFrameGif(imagePaths);
Assert.Equal(2, anyBitmap.FrameCount);
Assert.Equal(2, anyBitmap.GetAllFrames.Count());
anyBitmap.GetAllFrames.ElementAt(0).SaveAs("first.png");
Image first = Image.Load(GetRelativeFilePath("first-animated-qr.png"));
first.Mutate(img => img.Resize(new ResizeOptions
{
Size = new SixLabors.ImageSharp.Size(anyBitmap.GetAllFrames.ElementAt(0).Width, anyBitmap.GetAllFrames.ElementAt(0).Height),
Mode = SixLabors.ImageSharp.Processing.ResizeMode.BoxPad
}));
first.Save("first-expected.jpg");
AssertImageAreEqual("first-expected.jpg", "first.png", true);

anyBitmap.GetAllFrames.ElementAt(1).SaveAs("last.png");
Image last = Image.Load(GetRelativeFilePath("mountainclimbers.jpg"));
last.Mutate(img => img.Resize(new ResizeOptions
{
Size = new SixLabors.ImageSharp.Size(anyBitmap.GetAllFrames.ElementAt(1).Width, anyBitmap.GetAllFrames.ElementAt(1).Height),
Mode = SixLabors.ImageSharp.Processing.ResizeMode.BoxPad
}));
last.Save("last-expected.jpg");
AssertImageAreEqual("last-expected.jpg", "last.png", true);
}

[FactWithAutomaticDisplayName]
public void Should_Return_BitsPerPixel()
{
AnyBitmap bitmap = AnyBitmap.FromFile(GetRelativeFilePath("van-gogh-starry-night-vincent-van-gogh.jpg"));
Assert.Equal(24, bitmap.BitsPerPixel);

bitmap = SixLabors.ImageSharp.Image.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(GetRelativeFilePath("mountainclimbers.jpg"));
Assert.Equal(32, bitmap.BitsPerPixel);
}

#if !NET472
[FactWithAutomaticDisplayName]
public void CastMaui_to_AnyBitmap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,21 @@ public void Cast_ImageSharp_Rgba64_to_Color()
Assert.Equal(45232, imgColor.B);
}

[FactWithAutomaticDisplayName]
public void Should_Return_Argb()
{
System.Drawing.Color bmColor = System.Drawing.Color.Azure;
IronSoftware.Drawing.Color ironColor = IronSoftware.Drawing.Color.Azure;
IronSoftware.Drawing.Color fromImageSharp = SixLabors.ImageSharp.Color.Azure;
IronSoftware.Drawing.Color rgba32 = new SixLabors.ImageSharp.PixelFormats.Rgba32(bmColor.R, bmColor.G, bmColor.B, bmColor.A);
IronSoftware.Drawing.Color rgb24 = new SixLabors.ImageSharp.PixelFormats.Rgb24(bmColor.R, bmColor.G, bmColor.B);

Assert.Equal(bmColor.ToArgb(), ironColor.ToArgb());
Assert.Equal(bmColor.ToArgb(), fromImageSharp.ToArgb());
Assert.Equal(bmColor.ToArgb(), rgba32.ToArgb());
Assert.Equal(bmColor.ToArgb(), rgb24.ToArgb());
}

#if !NET472
[FactWithAutomaticDisplayName]
public void Cast_Maui_from_Color()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ public void CastSKRectI_from_CropRectangle()
Assert.Equal(215, rect.Bottom);
}

[FactWithAutomaticDisplayName]
public void ConvertMeasurement()
{
CropRectangle pxCropRect = new CropRectangle(15, 25, 150, 175);
CropRectangle mmCropRect = pxCropRect.ConvertTo(MeasurementUnits.Millimeters, 96);
Assert.Equal(3, mmCropRect.X);
Assert.Equal(6, mmCropRect.Y);
Assert.Equal(39, mmCropRect.Width);
Assert.Equal(46, mmCropRect.Height);
}

#if !NET472

[FactWithAutomaticDisplayName]
Expand Down
Loading