Browse Source

Merge branch 'master' into af/create-2.1-target

af/merge-core
James Jackson-South 8 years ago
committed by GitHub
parent
commit
ce656264e3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/ImageSharp/PixelFormats/Bgr24.cs
  2. 5
      src/ImageSharp/PixelFormats/Rgb24.cs
  3. 14
      src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs
  4. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs
  5. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs
  6. 8
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  7. 5
      tests/ImageSharp.Tests/Image/ImageCloneTests.cs
  8. 25
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
  9. 12
      tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

5
src/ImageSharp/PixelFormats/Bgr24.cs

@ -14,22 +14,25 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form. /// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para> /// </para>
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Explicit)]
public struct Bgr24 : IPixel<Bgr24> public struct Bgr24 : IPixel<Bgr24>
{ {
/// <summary> /// <summary>
/// The blue component. /// The blue component.
/// </summary> /// </summary>
[FieldOffset(0)]
public byte B; public byte B;
/// <summary> /// <summary>
/// The green component. /// The green component.
/// </summary> /// </summary>
[FieldOffset(1)]
public byte G; public byte G;
/// <summary> /// <summary>
/// The red component. /// The red component.
/// </summary> /// </summary>
[FieldOffset(2)]
public byte R; public byte R;
/// <summary> /// <summary>

5
src/ImageSharp/PixelFormats/Rgb24.cs

@ -15,22 +15,25 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form. /// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para> /// </para>
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Explicit)]
public struct Rgb24 : IPixel<Rgb24> public struct Rgb24 : IPixel<Rgb24>
{ {
/// <summary> /// <summary>
/// The red component. /// The red component.
/// </summary> /// </summary>
[FieldOffset(0)]
public byte R; public byte R;
/// <summary> /// <summary>
/// The green component. /// The green component.
/// </summary> /// </summary>
[FieldOffset(1)]
public byte G; public byte G;
/// <summary> /// <summary>
/// The blue component. /// The blue component.
/// </summary> /// </summary>
[FieldOffset(2)]
public byte B; public byte B;
/// <summary> /// <summary>

14
src/ImageSharp/Processing/Quantization/FrameQuantizers/WuFrameQuantizer{TPixel}.cs

@ -157,13 +157,13 @@ namespace SixLabors.ImageSharp.Processing.Quantization.FrameQuantizers
} }
finally finally
{ {
this.vwt.Dispose(); this.vwt?.Dispose();
this.vmr.Dispose(); this.vmr?.Dispose();
this.vmg.Dispose(); this.vmg?.Dispose();
this.vmb.Dispose(); this.vmb?.Dispose();
this.vma.Dispose(); this.vma?.Dispose();
this.m2.Dispose(); this.m2?.Dispose();
this.tag.Dispose(); this.tag?.Dispose();
} }
} }

2
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Baseline.cs

@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void DecodeBaselineJpeg_PdfJs<TPixel>(TestImageProvider<TPixel> provider) public void DecodeBaselineJpeg_PdfJs<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) if (SkipTest(provider))
{ {
// skipping to avoid OutOfMemoryException on CI // skipping to avoid OutOfMemoryException on CI
return; return;

2
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
public void DecodeProgressiveJpeg_Orig<TPixel>(TestImageProvider<TPixel> provider) public void DecodeProgressiveJpeg_Orig<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
if (TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess) if (SkipTest(provider))
{ {
// skipping to avoid OutOfMemoryException on CI // skipping to avoid OutOfMemoryException on CI
return; return;

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

@ -48,11 +48,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
string[] largeImagesToSkipOn32Bit = string[] largeImagesToSkipOn32Bit =
{ {
TestImages.Jpeg.Baseline.Jpeg420Exif, TestImages.Jpeg.Baseline.Jpeg420Exif,
TestImages.Jpeg.Issues.BadZigZagProgressive385 TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159,
TestImages.Jpeg.Issues.BadZigZagProgressive385,
TestImages.Jpeg.Issues.NoEoiProgressive517,
TestImages.Jpeg.Issues.BadRstProgressive518,
}; };
return TestEnvironment.RunsOnCI && !TestEnvironment.Is64BitProcess return !TestEnvironment.Is64BitProcess && largeImagesToSkipOn32Bit.Contains(provider.SourceFileOrDescription);
&& largeImagesToSkipOn32Bit.Contains(provider.SourceFileOrDescription);
} }
public JpegDecoderTests(ITestOutputHelper output) public JpegDecoderTests(ITestOutputHelper output)

5
tests/ImageSharp.Tests/Image/ImageCloneTests.cs

@ -33,10 +33,7 @@ namespace SixLabors.ImageSharp.Tests
} }
} }
/// <summary> [Theory]
/// https://github.com/SixLabors/ImageSharp/issues/576
/// </summary>
[Theory(Skip = "See https://github.com/SixLabors/ImageSharp/issues/576")]
[WithTestPatternImages(9, 9, PixelTypes.Rgba32)] [WithTestPatternImages(9, 9, PixelTypes.Rgba32)]
public void CloneAs_ToBgr24(TestImageProvider<Rgba32> provider) public void CloneAs_ToBgr24(TestImageProvider<Rgba32> provider)
{ {

25
tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs

@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests
public bool Equals(Key other) public bool Equals(Key other)
{ {
if (ReferenceEquals(null, other)) return false; if (other is null) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
if (!this.commonValues.Equals(other.commonValues)) return false; if (!this.commonValues.Equals(other.commonValues)) return false;
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (ReferenceEquals(null, obj)) return false; if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false; if (obj.GetType() != this.GetType()) return false;
return this.Equals((Key)obj); return this.Equals((Key)obj);
@ -133,15 +133,14 @@ namespace SixLabors.ImageSharp.Tests
{ {
Guard.NotNull(decoder, nameof(decoder)); Guard.NotNull(decoder, nameof(decoder));
Key key = new Key(this.PixelType, this.FilePath, decoder); if (!TestEnvironment.Is64BitProcess)
{
return LoadImage(decoder);
}
Image<TPixel> cachedImage = cache.GetOrAdd( var key = new Key(this.PixelType, this.FilePath, decoder);
key,
fn => Image<TPixel> cachedImage = cache.GetOrAdd(key, fn => { return LoadImage(decoder); });
{
var testFile = TestFile.Create(this.FilePath);
return Image.Load<TPixel>(this.Configuration, testFile.Bytes, decoder);
});
return cachedImage.Clone(); return cachedImage.Clone();
} }
@ -158,6 +157,12 @@ namespace SixLabors.ImageSharp.Tests
base.Serialize(info); base.Serialize(info);
info.AddValue("path", this.FilePath); info.AddValue("path", this.FilePath);
} }
private Image<TPixel> LoadImage(IImageDecoder decoder)
{
var testFile = TestFile.Create(this.FilePath);
return Image.Load<TPixel>(this.Configuration, testFile.Bytes, decoder);
}
} }
public static string GetFilePathOrNull(ITestImageProvider provider) public static string GetFilePathOrNull(ITestImageProvider provider)

12
tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

@ -121,6 +121,12 @@ namespace SixLabors.ImageSharp.Tests
public void GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache<TPixel>(TestImageProvider<TPixel> provider) public void GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
if (!TestEnvironment.Is64BitProcess)
{
// We don't cache with the 32 bit build.
return;
}
Assert.NotNull(provider.Utility.SourceFileOrDescription); Assert.NotNull(provider.Utility.SourceFileOrDescription);
TestDecoder.DoTestThreadSafe(() => TestDecoder.DoTestThreadSafe(() =>
@ -179,6 +185,12 @@ namespace SixLabors.ImageSharp.Tests
public void GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual<TPixel>(TestImageProvider<TPixel> provider) public void GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
if (!TestEnvironment.Is64BitProcess)
{
// We don't cache with the 32 bit build.
return;
}
Assert.NotNull(provider.Utility.SourceFileOrDescription); Assert.NotNull(provider.Utility.SourceFileOrDescription);
TestDecoderWithParameters.DoTestThreadSafe(() => TestDecoderWithParameters.DoTestThreadSafe(() =>

Loading…
Cancel
Save