Browse Source

Merge pull request #1383 from SixLabors/dl/upgrade-magick-net

Upgraded Magick.NET.
pull/1384/head
James Jackson-South 5 years ago
committed by GitHub
parent
commit
581efcf7c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      tests/Directory.Build.targets
  2. 6
      tests/ImageSharp.Tests/Formats/Tga/TgaTestUtils.cs
  3. 24
      tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs

2
tests/Directory.Build.targets

@ -29,7 +29,7 @@
<PackageReference Update="BenchmarkDotNet.Diagnostics.Windows" Version="0.12.1" Condition="'$(OS)' == 'Windows_NT'" />
<PackageReference Update="Colourful" Version="2.0.5" />
<PackageReference Update="coverlet.collector" Version="1.3.1-preview.27.gdd2237a3be" PrivateAssets="All"/>
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="7.15.5" />
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="7.22.0" />
<PackageReference Update="Microsoft.DotNet.RemoteExecutor" Version="5.0.0-beta.20069.1" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Update="Moq" Version="4.14.5" />

6
tests/ImageSharp.Tests/Formats/Tga/TgaTestUtils.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
Image<TPixel> image,
bool useExactComparer = true,
float compareTolerance = 0.01f)
where TPixel : unmanaged, IPixel<TPixel>
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel>
{
string path = TestImageProvider<TPixel>.GetFilePathOrNull(provider);
if (path == null)
@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
}
public static Image<TPixel> DecodeWithMagick<TPixel>(Configuration configuration, FileInfo fileInfo)
where TPixel : unmanaged, IPixel<TPixel>
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel>
{
using (var magickImage = new MagickImage(fileInfo))
{
@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
Assert.True(result.TryGetSinglePixelSpan(out Span<TPixel> resultPixels));
using (IPixelCollection pixels = magickImage.GetPixelsUnsafe())
using (IUnsafePixelCollection<ushort> pixels = magickImage.GetPixelsUnsafe())
{
byte[] data = pixels.ToByteArray(PixelMapping.RGBA);

24
tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs

@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using ImageMagick;
using ImageMagick.Formats.Bmp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
@ -18,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
public static MagickReferenceDecoder Instance { get; } = new MagickReferenceDecoder();
private static void FromRgba32Bytes<TPixel>(Configuration configuration, Span<byte> rgbaBytes, IMemoryGroup<TPixel> destinationGroup)
where TPixel : unmanaged, IPixel<TPixel>
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel>
{
foreach (Memory<TPixel> m in destinationGroup)
{
@ -33,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
}
private static void FromRgba64Bytes<TPixel>(Configuration configuration, Span<byte> rgbaBytes, IMemoryGroup<TPixel> destinationGroup)
where TPixel : unmanaged, IPixel<TPixel>
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel>
{
foreach (Memory<TPixel> m in destinationGroup)
{
@ -48,17 +49,28 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
}
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel>
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel>
=> Task.FromResult(this.Decode<TPixel>(configuration, stream));
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
where TPixel : unmanaged, IPixel<TPixel>
where TPixel : unmanaged, ImageSharp.PixelFormats.IPixel<TPixel>
{
using var magickImage = new MagickImage(stream);
var bmpReadDefines = new BmpReadDefines
{
// See https://github.com/SixLabors/ImageSharp/issues/1380
// Validation fails on Ubuntu despite identical header generation
// on all platforms.
IgnoreFileSize = !TestEnvironment.IsWindows
};
var settings = new MagickReadSettings();
settings.SetDefines(bmpReadDefines);
using var magickImage = new MagickImage(stream, settings);
var result = new Image<TPixel>(configuration, magickImage.Width, magickImage.Height);
MemoryGroup<TPixel> resultPixels = result.GetRootFramePixelBuffer().FastMemoryGroup;
using (IPixelCollection pixels = magickImage.GetPixelsUnsafe())
using (IUnsafePixelCollection<ushort> pixels = magickImage.GetPixelsUnsafe())
{
if (magickImage.Depth == 8)
{

Loading…
Cancel
Save