Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ public void AnyBitmap_should_get_Bytes()
Assert.Equal(expected, resultExport);
}

#if !NET48
[FactWithAutomaticDisplayName]
public void AnyBitmap_should_set_Pixel()
{
Expand Down Expand Up @@ -291,7 +290,6 @@ public void AnyBitmap_should_set_Pixel()
#endif
}
}
#endif

[FactWithAutomaticDisplayName]
public void AnyBitmap_should_get_Stream()
Expand Down Expand Up @@ -341,7 +339,6 @@ public void AnyBitmap_should_ToString()
Assert.Equal(expected, result);
}

#if !NET48
[FactWithAutomaticDisplayName]
public void AnyBitmap_GetPixel_should_not_throw_OutOfMemoryException()
{
Expand Down Expand Up @@ -393,7 +390,6 @@ public void Clone_AnyBitmap()

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

[FactWithAutomaticDisplayName]
public void Clone_Crop_AnyBitmap()
Expand Down Expand Up @@ -477,7 +473,6 @@ public void CastSKImage_from_AnyBitmap()
AssertImageAreEqual("expected.png", "result.png", true);
}

#if !NET48
[FactWithAutomaticDisplayName]
public void CastSixLabors_to_AnyBitmap()
{
Expand Down Expand Up @@ -538,7 +533,6 @@ public void CastSixLabors_from_AnyBitmap_Rgba32(string filename)

AssertImageAreEqual("expected.bmp", "result.bmp", true);
}
#endif

[FactWithAutomaticDisplayName]
public void CastBitmap_to_AnyBitmap_using_FromBitmap()
Expand Down Expand Up @@ -717,7 +711,6 @@ public void Create_Multi_page_Tiff_Paths()
File.Delete(outputImagePath);
}

#if !NET48
[FactWithAutomaticDisplayName]
public void CreateMultiFrameTiffStream_Preserves_Mixed_Orientation()
{
Expand Down Expand Up @@ -760,7 +753,6 @@ public void CreateMultiFrameTiffBytes_Preserves_Per_Page_Dimensions_And_Resoluti
.Should().BeApproximately(150d, 2d);
}
}
#endif

[FactWithAutomaticDisplayName]
public void CreateMultiFrameTiffStream_Empty_Sequence_Throws()
Expand All @@ -769,7 +761,6 @@ public void CreateMultiFrameTiffStream_Empty_Sequence_Throws()
act.Should().Throw<ArgumentException>();
}

#if !NET48
[FactWithAutomaticDisplayName]
public void CreateMultiFrameTiffBytes_PreservesResolution_FromPixelsPerMeterSource()
{
Expand All @@ -786,7 +777,6 @@ public void CreateMultiFrameTiffBytes_PreservesResolution_FromPixelsPerMeterSour
ToDotsPerInch(pages[0].XResolution, pages[0].ResolutionUnit)
.Should().BeApproximately(dpi, 2d);
}
#endif

[FactWithAutomaticDisplayName]
public void CreateMultiFrameTiff_Preserves_Rgb24_Pixels()
Expand Down Expand Up @@ -828,7 +818,6 @@ public void CreateMultiFrameTiff_Preserves_Rgb24_Pixels()
}
}

#if !NET48
[TheoryWithAutomaticDisplayName]
[InlineData("Rgb24")]
[InlineData("Bgr24")]
Expand Down Expand Up @@ -893,7 +882,6 @@ private static AnyBitmap MakeBitmapWithResolution(int width, int height, Rgb24 c
image.Metadata.ResolutionUnits = unit;
return image;
}
#endif

private static List<(int Width, int Height, float XResolution, ResUnit ResolutionUnit)> ReadTiffDirectories(byte[] tiffData)
{
Expand Down Expand Up @@ -934,7 +922,6 @@ private static double ToDotsPerInch(float xResolution, ResUnit unit)
};
}

#if !NET48
[FactWithAutomaticDisplayName]
public void Create_Multi_page_Gif()
{
Expand Down Expand Up @@ -1010,7 +997,6 @@ public void Should_Return_BitsPerPixel()
bitmap = Image.Load<Rgba32>(GetRelativeFilePath("mountainclimbers.jpg"));
Assert.Equal(32, bitmap.BitsPerPixel);
}
#endif

[TheoryWithAutomaticDisplayName]
[InlineData("ScanDev_BW.tif", 1)]
Expand Down Expand Up @@ -1196,7 +1182,6 @@ public void Resize_ShouldPreserveDepthForRepresentableFormats()
}
}

#if !NET48
[TheoryWithAutomaticDisplayName]
[InlineData("A8", "GrayscaleWithAlpha", "Bit8", 16)]
[InlineData("L8", "Grayscale", "Bit8", 8)]
Expand Down Expand Up @@ -1243,7 +1228,6 @@ public void ExportPng_ShouldChooseColorTypeAndBitDepthFromPixelType(
}
Assert.Equal(expectedBitsPerPixel, AnyBitmap.FromBytes(png).BitsPerPixel);
}
#endif

[TheoryWithAutomaticDisplayName]
[InlineData("Palette", "Bit8")]
Expand Down Expand Up @@ -1394,7 +1378,6 @@ public void Should_RotateFlip()
AssertImageAreEqual(GetRelativeFilePath("checkmarkFlip.jpg"), "result_flip.bmp");
}

#if !NET48
[FactWithAutomaticDisplayName]
public void Redact_ShouldRedactRegionWithColor()
{
Expand Down Expand Up @@ -1435,7 +1418,6 @@ public void Redact_ShouldRedactRegionWithColor()
}
}
}
#endif

[FactWithAutomaticDisplayName]
public void TestGetRGBBuffer()
Expand Down Expand Up @@ -1681,7 +1663,6 @@ public void LoadImage_SetPreserveOriginalFormat_ShouldReturnCorrectBitPerPixel(s
}

#if !NET7_0
#if !NET48
[FactWithAutomaticDisplayName]
public void CastAnyBitmap_from_SixLabors()
{
Expand All @@ -1697,7 +1678,6 @@ public void CastAnyBitmap_from_SixLabors()
AssertLargeImageAreEqual("expected.bmp", "result.bmp", true);
}
#endif
#endif


[IgnoreOnAzureDevopsX86Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ public void Cast_SKColor_to_Color()
Assert.Equal(176, skColor.Blue);
}

#if !NET48
[FactWithAutomaticDisplayName]
public void Cast_ImageSharp_Color_from_Color()
{
Expand Down Expand Up @@ -558,7 +557,6 @@ public void Should_Return_Argb()
Assert.Equal(bmColor.ToArgb(), rgba32.ToArgb());
Assert.Equal(bmColor.ToArgb(), rgb24.ToArgb());
}
#endif

[FactWithAutomaticDisplayName]
public void Should_Create_FromName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,9 @@ protected static void AssertLargeImageAreEqual(string expectedImagePath, string
expectedImageSharp.Mutate(x => x.Resize(100, 100));
actualImageSharp.Mutate(x => x.Resize(100, 100));

#if NET48
// The ImageSharp casts are not available on .NET Framework; go through PNG bytes instead.
AssertImageAreEqual(ToAnyBitmap(expectedImageSharp), ToAnyBitmap(actualImageSharp));
#else
AssertImageAreEqual(expectedImageSharp, actualImageSharp);
#endif
}

#if NET48
private static AnyBitmap ToAnyBitmap(SixLabors.ImageSharp.Image image)
{
using var stream = new MemoryStream();
SixLabors.ImageSharp.ImageExtensions.SaveAsPng(image, stream);
return AnyBitmap.FromBytes(stream.ToArray());
}
#endif

protected static void AssertImageAreEqual(string expectedImagePath, string resultImagePath, bool isCleanAll = false)
{
using var expected = AnyBitmap.FromFile(expectedImagePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void CastRectangle_from_Rectangle()
Assert.Equal(5, rectangle.Y);
}

#if !NET48
[FactWithAutomaticDisplayName]
public void CastImageSharp_Rectangle_to_Rectangle()
{
Expand Down Expand Up @@ -138,7 +137,6 @@ public void CastImageSharp_RectangleF_from_Rectangle()
Assert.Equal(5, rectangle.X);
Assert.Equal(5, rectangle.Y);
}
#endif

[FactWithAutomaticDisplayName]
public void CastSKRect_to_Rectangle()
Expand Down Expand Up @@ -413,7 +411,6 @@ public void CastRectangleF_from_RectangleF()
Assert.Equal(5, Rectangle.Y);
}

#if !NET48
[FactWithAutomaticDisplayName]
public void CastImageSharp_RectangleF_to_RectangleF()
{
Expand Down Expand Up @@ -446,7 +443,6 @@ public void CastImageSharp_RectangleF_from_RectangleF()
Assert.Equal(5, Rectangle.X);
Assert.Equal(5, Rectangle.Y);
}
#endif

[FactWithAutomaticDisplayName]
public void CastSKRect_to_RectangleF()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,16 @@ public void CreateMultiFrameTiff_BigTiffWithOversizedIfdCount_FailsFast()
}
}

#if !NET48
[FactWithAutomaticDisplayName]
public void ImageSharpLoader_BigTiffWithOversizedIfdCount_FailsFast()
{
byte[] bytes = CreateBigTiffWithOversizedIfdCount();
ShouldFailFast(() => ImageSharpLoader.Load(bytes));
ShouldFailFast(() => ImageSharpLoader.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(bytes));
ShouldFailFast(() => ImageSharpLoader.Load(new MemoryStream(bytes)));
ShouldFailFast(() => ImageSharpLoader.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(bytes));
ShouldFailFast(() => ImageSharpLoader.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(new MemoryStream(bytes)));
}
#endif

#if !NET48
[FactWithAutomaticDisplayName]
public void ImageSharpLoader_ValidImage_MatchesImageLoad()
{
Expand All @@ -150,14 +147,26 @@ public void ImageSharpLoader_ValidImage_MatchesImageLoad()
using var expected = SixLabors.ImageSharp.Image.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(bytes);
using var fromBytes = ImageSharpLoader.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(bytes);
using var fromStream = ImageSharpLoader.Load(new MemoryStream(bytes));
using var typedFromStream = ImageSharpLoader.Load<SixLabors.ImageSharp.PixelFormats.Rgb24>(new MemoryStream(bytes));

fromBytes.Width.Should().Be(expected.Width);
fromBytes.Height.Should().Be(expected.Height);
fromBytes[10, 10].Should().Be(expected[10, 10]);
fromStream.Width.Should().Be(expected.Width);
fromStream.Height.Should().Be(expected.Height);
typedFromStream.Width.Should().Be(expected.Width);
typedFromStream[10, 10].Should().Be(expected[10, 10].Rgb);
}

[FactWithAutomaticDisplayName]
public void ImageSharpLoader_GenericLoad_InvalidData_ThrowsImageSharpException()
{
// On .NET Framework the generic overloads call ImageSharp through reflection; callers must still get
// ImageSharp's own exception, not a TargetInvocationException.
byte[] garbage = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
Action load = () => ImageSharpLoader.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(garbage);
load.Should().Throw<SixLabors.ImageSharp.UnknownImageFormatException>();
}
#endif

[FactWithAutomaticDisplayName]
public void FromBytes_ValidBigTiff_StillLoads()
Expand Down
Loading
Loading