Browse Source

jpeg test cleanup

af/merge-core
Anton Firszov 9 years ago
parent
commit
41731c72cc
  1. 17
      tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj
  2. 2
      tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs
  3. 2
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
  4. 38
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  5. 75
      tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
  6. 78
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
  7. 279
      tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs
  8. 6
      tests/ImageSharp.Tests/Formats/Jpg/JpegUtilityTestFixture.cs
  9. 108
      tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs
  10. 2
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs
  11. 1
      tests/ImageSharp.Tests/TestImages.cs

17
tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj

@ -97,11 +97,20 @@
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\Block8x8FTests.cs">
<Link>Tests\Formats\Jpg\Block8x8FTests.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\JpegTestBase.cs">
<Link>Tests\Formats\Jpg\JpegTestBase.cs</Link>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\JpegDecoderTests.cs">
<Link>Tests\Formats\Jpg\JpegDecoderTests.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\JpegTests.cs">
<Link>Tests\Formats\Jpg\JpegTests.cs</Link>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\JpegEncoderTests.cs">
<Link>Tests\Formats\Jpg\JpegEncoderTests.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\JpegProfilingBenchmarks.cs">
<Link>Tests\Formats\Jpg\JpegProfilingBenchmarks.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\JpegUtilityTestFixture.cs">
<Link>Tests\Formats\Jpg\JpegUtilityTestFixture.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\JpegUtilsTests.cs">
<Link>Tests\Formats\Jpg\JpegUtilsTests.cs</Link>
</Compile>
<Compile Include="..\ImageSharp.Tests\Formats\Jpg\ReferenceImplementations.cs">
<Link>Tests\Formats\Jpg\ReferenceImplementations.cs</Link>

2
tests/ImageSharp.Tests/Formats/Jpg/BadEofJpegTests.cs

@ -1,4 +1,4 @@
// <copyright file="JpegTests.cs" company="James Jackson-South">
// <copyright file="JpegEncoderTests.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>

2
tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs

@ -19,7 +19,7 @@ namespace ImageSharp.Tests
using Xunit;
using Xunit.Abstractions;
public class Block8x8FTests : JpegTestBase
public class Block8x8FTests : JpegUtilityTestFixture
{
#if BENCHMARKING
public const int Times = 1000000;

38
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -0,0 +1,38 @@
namespace ImageSharp.Tests
{
using System;
using Xunit;
public class JpegDecoderTests : TestBase
{
public static string[] BaselineTestJpegs =
{
TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk,
TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.Jpeg444
};
public static string[] ProgressiveTestJpegs = TestImages.Jpeg.Progressive.All;
[Theory]
[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb)]
public void OpenBaselineJpeg_SaveBmp<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage();
provider.Utility.SaveTestOutputFile(image, "bmp");
}
[Theory]
[WithFileCollection(nameof(ProgressiveTestJpegs), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb)]
public void OpenProgressiveJpeg_SaveBmp<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage();
provider.Utility.SaveTestOutputFile(image, "bmp");
}
}
}

75
tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs

@ -0,0 +1,75 @@
// <copyright file="JpegTests.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ImageSharp.Formats;
using Xunit;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming
namespace ImageSharp.Tests
{
using ImageSharp.Formats.Jpg;
using ImageSharp.Processing;
public class JpegEncoderTests : MeasureFixture
{
public static IEnumerable<string> AllBmpFiles => TestImages.Bmp.All;
public JpegEncoderTests(ITestOutputHelper output)
: base(output)
{
}
[Theory]
[WithFile(TestImages.Jpeg.Baseline.Snake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio420)]
[WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio420)]
[WithFile(TestImages.Jpeg.Baseline.Snake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio444)]
[WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio444)]
public void LoadResizeSave<TColor>(TestImageProvider<TColor> provider, int quality, JpegSubsample subsample)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage()
.Resize(new ResizeOptions
{
Size = new Size(150, 100),
Mode = ResizeMode.Max
});
image.Quality = quality;
image.ExifProfile = null; // Reduce the size of the file
JpegEncoder encoder = new JpegEncoder { Subsample = subsample, Quality = quality };
provider.Utility.TestName += $"{subsample}_Q{quality}";
provider.Utility.SaveTestOutputFile(image, "png");
provider.Utility.SaveTestOutputFile(image, "jpg", encoder);
}
[Theory]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb, JpegSubsample.Ratio420, 75)]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb, JpegSubsample.Ratio444, 75)]
public void OpenBmp_SaveJpeg<TColor>(TestImageProvider<TColor> provider, JpegSubsample subSample, int quality)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage();
ImagingTestCaseUtility utility = provider.Utility;
utility.TestName += "_" + subSample + "_Q" + quality;
using (var outputStream = File.OpenWrite(utility.GetTestOutputFileName("jpg")))
{
var encoder = new JpegEncoder()
{
Subsample = subSample,
Quality = quality
};
image.Save(outputStream, encoder);
}
}
}
}

78
tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs

@ -0,0 +1,78 @@
namespace ImageSharp.Tests
{
using System;
using System.IO;
using System.Linq;
using ImageSharp.Formats;
using Xunit;
using Xunit.Abstractions;
public class JpegProfilingBenchmarks : MeasureFixture
{
public JpegProfilingBenchmarks(ITestOutputHelper output)
: base(output)
{
}
// [Theory] // Benchmark, enable manually
[InlineData(30, TestImages.Jpeg.Baseline.Cmyk)]
[InlineData(30, TestImages.Jpeg.Baseline.Ycck)]
[InlineData(30, TestImages.Jpeg.Baseline.Calliphora)]
[InlineData(30, TestImages.Jpeg.Baseline.Jpeg400)]
[InlineData(30, TestImages.Jpeg.Baseline.Jpeg420)]
[InlineData(30, TestImages.Jpeg.Baseline.Jpeg444)]
public void DecodeJpeg(int executionCount, string fileName)
{
string path = TestFile.GetPath(fileName);
byte[] bytes = File.ReadAllBytes(path);
this.Measure(
100,
() =>
{
Image img = new Image(bytes);
},
// ReSharper disable once ExplicitCallerInfoArgument
$"Decode {fileName}");
}
// Benchmark, enable manually!
// [Theory]
[InlineData(1, 75, JpegSubsample.Ratio420)]
[InlineData(30, 75, JpegSubsample.Ratio420)]
[InlineData(30, 75, JpegSubsample.Ratio444)]
[InlineData(30, 100, JpegSubsample.Ratio444)]
public void EncodeJpeg(int executionCount, int quality, JpegSubsample subsample)
{
string[] testFiles = TestImages.Bmp.All
.Concat(new[] { TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk })
.ToArray();
Image<Color>[] testImages =
testFiles.Select(
tf => TestImageProvider<Color>.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage())
.ToArray();
using (MemoryStream ms = new MemoryStream())
{
this.Measure(executionCount,
() =>
{
foreach (Image<Color> img in testImages)
{
JpegEncoder encoder = new JpegEncoder() { Quality = quality, Subsample = subsample };
img.Save(ms, encoder);
ms.Seek(0, SeekOrigin.Begin);
}
},
// ReSharper disable once ExplicitCallerInfoArgument
$@"Encode {testFiles.Length} images"
);
}
}
}
}

279
tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs

@ -1,279 +0,0 @@
// <copyright file="JpegTests.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ImageSharp.Formats;
using Xunit;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming
namespace ImageSharp.Tests
{
using System.Numerics;
using ImageSharp.Formats.Jpg;
using ImageSharp.Processing;
public class JpegTests : MeasureFixture
{
public JpegTests(ITestOutputHelper output)
: base(output)
{
}
[Theory]
[WithFile(TestImages.Jpeg.Baseline.Snake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio420)]
[WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio420)]
[WithFile(TestImages.Jpeg.Baseline.Snake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio444)]
[WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.StandardImageClass, 75, JpegSubsample.Ratio444)]
public void LoadResizeSave<TColor>(TestImageProvider<TColor> provider, int quality, JpegSubsample subsample)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage()
.Resize(new ResizeOptions
{
Size = new Size(150, 100),
Mode = ResizeMode.Max
});
image.Quality = quality;
image.ExifProfile = null; // Reduce the size of the file
JpegEncoder encoder = new JpegEncoder { Subsample = subsample, Quality = quality };
provider.Utility.TestName += $"{subsample}_Q{quality}";
provider.Utility.SaveTestOutputFile(image, "png");
provider.Utility.SaveTestOutputFile(image, "jpg", encoder);
}
// Benchmark, enable manually!
// [Theory]
[InlineData(1, 75, JpegSubsample.Ratio420)]
[InlineData(30, 75, JpegSubsample.Ratio420)]
[InlineData(30, 75, JpegSubsample.Ratio444)]
[InlineData(30, 100, JpegSubsample.Ratio444)]
public void Encoder_Benchmark(int executionCount, int quality, JpegSubsample subsample)
{
string[] testFiles = TestImages.Bmp.All
.Concat(new[] { TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk })
.ToArray();
Image<Color>[] testImages =
testFiles.Select(
tf => TestImageProvider<Color>.File(tf, pixelTypeOverride: PixelTypes.StandardImageClass).GetImage())
.ToArray();
using (MemoryStream ms = new MemoryStream())
{
this.Measure(executionCount,
() =>
{
foreach (Image<Color> img in testImages)
{
JpegEncoder encoder = new JpegEncoder() { Quality = quality, Subsample = subsample };
img.Save(ms, encoder);
ms.Seek(0, SeekOrigin.Begin);
}
},
// ReSharper disable once ExplicitCallerInfoArgument
$@"Encode {testFiles.Length} images"
);
}
}
public static IEnumerable<string> AllJpegFiles => TestImages.Jpeg.Baseline.All;
[Theory]
[WithFileCollection(nameof(AllJpegFiles), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb)]
public void OpenJpeg_SaveBmp<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage();
provider.Utility.SaveTestOutputFile(image, "bmp");
}
public static IEnumerable<string> AllBmpFiles => TestImages.Bmp.All;
[Theory]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb, JpegSubsample.Ratio420, 75)]
[WithFileCollection(nameof(AllBmpFiles), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb, JpegSubsample.Ratio444, 75)]
public void OpenBmp_SaveJpeg<TColor>(TestImageProvider<TColor> provider, JpegSubsample subSample, int quality)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage();
ImagingTestCaseUtility utility = provider.Utility;
utility.TestName += "_" + subSample + "_Q" + quality;
using (var outputStream = File.OpenWrite(utility.GetTestOutputFileName("jpg")))
{
var encoder = new JpegEncoder()
{
Subsample = subSample,
Quality = quality
};
image.Save(outputStream, encoder);
}
}
private const int BenchmarkExecTimes = 30;
public static readonly string[] EncoderBenchmarkFiles =
{
TestImages.Bmp.Car, TestImages.Bmp.NegHeight,
TestImages.Bmp.F, TestImages.Png.Splash,
TestImages.Jpeg.Baseline.Jpeg420, TestImages.Jpeg.Baseline.Calliphora,
TestImages.Jpeg.Baseline.Cmyk
};
private const PixelTypes BenchmarkPixels = PixelTypes.StandardImageClass; //PixelTypes.Color | PixelTypes.Argb;
//[Theory] // Benchmark, enable manually
[InlineData(TestImages.Jpeg.Baseline.Cmyk)]
[InlineData(TestImages.Jpeg.Baseline.Ycck)]
[InlineData(TestImages.Jpeg.Baseline.Calliphora)]
[InlineData(TestImages.Jpeg.Baseline.Jpeg400)]
[InlineData(TestImages.Jpeg.Baseline.Jpeg420)]
[InlineData(TestImages.Jpeg.Baseline.Jpeg444)]
public void Benchmark_JpegDecoder(string fileName)
{
string path = TestFile.GetPath(fileName);
byte[] bytes = File.ReadAllBytes(path);
this.Measure(
100,
() =>
{
Image img = new Image(bytes);
},
// ReSharper disable once ExplicitCallerInfoArgument
$"Decode {fileName}");
}
//[Theory] // Benchmark, enable manually
[WithFileCollection(nameof(EncoderBenchmarkFiles), BenchmarkPixels, JpegSubsample.Ratio420, 75)]
[WithFileCollection(nameof(EncoderBenchmarkFiles), BenchmarkPixels, JpegSubsample.Ratio444, 75)]
public void Benchmark_JpegEncoder<TColor>(TestImageProvider<TColor> provider, JpegSubsample subSample, int quality)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = provider.GetImage();
using (var outputStream = new MemoryStream())
{
JpegEncoder encoder = new JpegEncoder()
{
Subsample = subSample,
Quality = quality
};
for (int i = 0; i < BenchmarkExecTimes; i++)
{
image.Save(outputStream, encoder);
outputStream.Seek(0, SeekOrigin.Begin);
}
}
}
public static Image<TColor> CreateTestImage<TColor>(GenericFactory<TColor> factory)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = factory.CreateImage(10, 10);
using (PixelAccessor<TColor> pixels = image.Lock())
{
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
Vector4 v = new Vector4(i/10f, j/10f, 0, 1);
TColor color = default(TColor);
color.PackFromVector4(v);
pixels[i, j] = color;
}
}
}
return image;
}
[Theory]
[WithMemberFactory(nameof(CreateTestImage), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb)]
public void CopyStretchedRGBTo_FromOrigo<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> src = provider.GetImage();
PixelArea<TColor> area = new PixelArea<TColor>(8, 8, ComponentOrder.Xyz);
Image<TColor> dest = provider.Factory.CreateImage(8, 8);
using (var s = src.Lock())
{
using (var d = dest.Lock())
{
s.CopyRGBBytesStretchedTo(area, 0, 0);
d.CopyFrom(area, 0, 0);
Assert.Equal(s[0, 0], d[0, 0]);
Assert.Equal(s[7, 0], d[7, 0]);
Assert.Equal(s[0, 7], d[0, 7]);
Assert.Equal(s[7, 7], d[7, 7]);
}
}
}
[Theory]
[WithMemberFactory(nameof(CreateTestImage), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb)]
public void CopyStretchedRGBTo_WithOffset<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> src = provider.GetImage();
PixelArea<TColor> area = new PixelArea<TColor>(8, 8, ComponentOrder.Xyz);
Image<TColor> dest = provider.Factory.CreateImage(8, 8);
using (PixelAccessor<TColor> s = src.Lock())
{
using (var d = dest.Lock())
{
s.CopyRGBBytesStretchedTo(area, 7, 6);
d.CopyFrom(area, 0, 0);
Assert.Equal(s[6, 7], d[0, 0]);
Assert.Equal(s[6, 8], d[0, 1]);
Assert.Equal(s[7, 8], d[1, 1]);
Assert.Equal(s[6, 9], d[0, 2]);
Assert.Equal(s[6, 9], d[0, 3]);
Assert.Equal(s[6, 9], d[0, 7]);
Assert.Equal(s[7, 9], d[1, 2]);
Assert.Equal(s[7, 9], d[1, 3]);
Assert.Equal(s[7, 9], d[1, 7]);
Assert.Equal(s[9, 9], d[3, 2]);
Assert.Equal(s[9, 9], d[3, 3]);
Assert.Equal(s[9, 9], d[3, 7]);
Assert.Equal(s[9, 7], d[3, 0]);
Assert.Equal(s[9, 7], d[4, 0]);
Assert.Equal(s[9, 7], d[7, 0]);
Assert.Equal(s[9, 9], d[3, 2]);
Assert.Equal(s[9, 9], d[4, 2]);
Assert.Equal(s[9, 9], d[7, 2]);
Assert.Equal(s[9, 9], d[4, 3]);
Assert.Equal(s[9, 9], d[7, 7]);
}
}
}
}
}

6
tests/ImageSharp.Tests/Formats/Jpg/JpegTestBase.cs → tests/ImageSharp.Tests/Formats/Jpg/JpegUtilityTestFixture.cs

@ -1,4 +1,4 @@
// <copyright file="JpegTestBase.cs" company="James Jackson-South">
// <copyright file="JpegUtilityTestFixture.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -16,9 +16,9 @@ namespace ImageSharp.Tests
using ImageSharp.Formats.Jpg;
public class JpegTestBase : MeasureFixture
public class JpegUtilityTestFixture : MeasureFixture
{
public JpegTestBase(ITestOutputHelper output) : base(output)
public JpegUtilityTestFixture(ITestOutputHelper output) : base(output)
{
}

108
tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs

@ -0,0 +1,108 @@
// ReSharper disable InconsistentNaming
namespace ImageSharp.Tests
{
using System;
using System.Numerics;
using ImageSharp.Formats.Jpg;
using Xunit;
public class JpegUtilsTests : TestBase
{
public static Image<TColor> CreateTestImage<TColor>(GenericFactory<TColor> factory)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> image = factory.CreateImage(10, 10);
using (PixelAccessor<TColor> pixels = image.Lock())
{
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
Vector4 v = new Vector4(i / 10f, j / 10f, 0, 1);
TColor color = default(TColor);
color.PackFromVector4(v);
pixels[i, j] = color;
}
}
}
return image;
}
[Theory]
[WithMemberFactory(nameof(CreateTestImage), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb)]
public void CopyStretchedRGBTo_FromOrigo<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> src = provider.GetImage();
PixelArea<TColor> area = new PixelArea<TColor>(8, 8, ComponentOrder.Xyz);
Image<TColor> dest = provider.Factory.CreateImage(8, 8);
using (var s = src.Lock())
{
using (var d = dest.Lock())
{
s.CopyRGBBytesStretchedTo(area, 0, 0);
d.CopyFrom(area, 0, 0);
Assert.Equal(s[0, 0], d[0, 0]);
Assert.Equal(s[7, 0], d[7, 0]);
Assert.Equal(s[0, 7], d[0, 7]);
Assert.Equal(s[7, 7], d[7, 7]);
}
}
}
[Theory]
[WithMemberFactory(nameof(CreateTestImage), PixelTypes.Color | PixelTypes.StandardImageClass | PixelTypes.Argb)]
public void CopyStretchedRGBTo_WithOffset<TColor>(TestImageProvider<TColor> provider)
where TColor : struct, IPackedPixel, IEquatable<TColor>
{
Image<TColor> src = provider.GetImage();
PixelArea<TColor> area = new PixelArea<TColor>(8, 8, ComponentOrder.Xyz);
Image<TColor> dest = provider.Factory.CreateImage(8, 8);
using (PixelAccessor<TColor> s = src.Lock())
{
using (var d = dest.Lock())
{
s.CopyRGBBytesStretchedTo(area, 7, 6);
d.CopyFrom(area, 0, 0);
Assert.Equal(s[6, 7], d[0, 0]);
Assert.Equal(s[6, 8], d[0, 1]);
Assert.Equal(s[7, 8], d[1, 1]);
Assert.Equal(s[6, 9], d[0, 2]);
Assert.Equal(s[6, 9], d[0, 3]);
Assert.Equal(s[6, 9], d[0, 7]);
Assert.Equal(s[7, 9], d[1, 2]);
Assert.Equal(s[7, 9], d[1, 3]);
Assert.Equal(s[7, 9], d[1, 7]);
Assert.Equal(s[9, 9], d[3, 2]);
Assert.Equal(s[9, 9], d[3, 3]);
Assert.Equal(s[9, 9], d[3, 7]);
Assert.Equal(s[9, 7], d[3, 0]);
Assert.Equal(s[9, 7], d[4, 0]);
Assert.Equal(s[9, 7], d[7, 0]);
Assert.Equal(s[9, 9], d[3, 2]);
Assert.Equal(s[9, 9], d[4, 2]);
Assert.Equal(s[9, 9], d[7, 2]);
Assert.Equal(s[9, 9], d[4, 3]);
Assert.Equal(s[9, 9], d[7, 7]);
}
}
}
}
}

2
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Tests.Formats.Jpg
using Xunit;
using Xunit.Abstractions;
public class ReferenceImplementationsTests : JpegTestBase
public class ReferenceImplementationsTests : JpegUtilityTestFixture
{
public ReferenceImplementationsTests(ITestOutputHelper output)
: base(output)

1
tests/ImageSharp.Tests/TestImages.cs

@ -66,7 +66,6 @@ namespace ImageSharp.Tests
public const string Lake = "Jpg/baseline/Lake.jpg";
public const string Jpeg400 = "Jpg/baseline/jpeg400jfif.jpg";
public const string Jpeg420 = "Jpg/baseline/jpeg420exif.jpg";
public const string Jpeg422 = "Jpg/baseline/jpeg422jfif.jpg";
public const string Jpeg444 = "Jpg/baseline/jpeg444.jpg";
public static readonly string[] All =

Loading…
Cancel
Save