Browse Source

Resize: do not premultiply pixels with no alpha

pull/1773/head
Anton Firszov 5 years ago
parent
commit
06566c5ab3
  1. 4
      src/ImageSharp/PixelFormats/Utils/Vector4Converters.cs
  2. 3
      src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs
  3. 31
      tests/ImageSharp.Benchmarks/Processing/Resize.cs
  4. 102
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
  5. 0
      tests/Images/External/ReferenceOutput/ResizeTests/CanResizeLargeImageWithCropMode_issue1006-incorrect-resize.png
  6. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeFromSourceRectangle_CalliphoraPartial.png
  7. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeHeightAndKeepAspect_CalliphoraPartial.png
  8. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWidthAndKeepAspect_CalliphoraPartial.png
  9. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithBoxPadMode_CalliphoraPartial.png
  10. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithCropHeightMode_CalliphoraPartial.png
  11. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithCropWidthMode_CalliphoraPartial.png
  12. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithMaxMode_CalliphoraPartial.png
  13. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithMinMode_CalliphoraPartial.png
  14. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithPadMode_CalliphoraPartial.png
  15. 0
      tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithStretchMode_CalliphoraPartial.png
  16. 3
      tests/Images/External/ReferenceOutput/ResizeTests/Resize_IsNotBoundToSinglePixelType_Bgr24_TestPattern50x50.png

4
src/ImageSharp/PixelFormats/Utils/Vector4Converters.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
/// <summary> /// <summary>
/// Apply modifiers used requested by ToVector4() conversion. /// Apply modifiers used requested by ToVector4() conversion.
/// </summary> /// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(InliningOptions.ShortMethod)]
internal static void ApplyForwardConversionModifiers(Span<Vector4> vectors, PixelConversionModifiers modifiers) internal static void ApplyForwardConversionModifiers(Span<Vector4> vectors, PixelConversionModifiers modifiers)
{ {
if (modifiers.IsDefined(PixelConversionModifiers.SRgbCompand)) if (modifiers.IsDefined(PixelConversionModifiers.SRgbCompand))
@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.PixelFormats.Utils
/// <summary> /// <summary>
/// Apply modifiers used requested by FromVector4() conversion. /// Apply modifiers used requested by FromVector4() conversion.
/// </summary> /// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(InliningOptions.ShortMethod)]
internal static void ApplyBackwardConversionModifiers(Span<Vector4> vectors, PixelConversionModifiers modifiers) internal static void ApplyBackwardConversionModifiers(Span<Vector4> vectors, PixelConversionModifiers modifiers)
{ {
if (modifiers.IsDefined(PixelConversionModifiers.Premultiply)) if (modifiers.IsDefined(PixelConversionModifiers.Premultiply))

3
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor{TPixel}.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
@ -187,6 +188,8 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
bool compand, bool compand,
bool premultiplyAlpha) bool premultiplyAlpha)
{ {
bool pixelHasNoAlpha = PixelOperations<TPixel>.Instance.GetPixelTypeInfo()?.AlphaRepresentation == PixelAlphaRepresentation.None;
premultiplyAlpha &= !pixelHasNoAlpha;
PixelConversionModifiers conversionModifiers = GetModifiers(compand, premultiplyAlpha); PixelConversionModifiers conversionModifiers = GetModifiers(compand, premultiplyAlpha);
Buffer2DRegion<TPixel> sourceRegion = source.PixelBuffer.GetRegion(sourceRectangle); Buffer2DRegion<TPixel> sourceRegion = source.PixelBuffer.GetRegion(sourceRectangle);

31
tests/ImageSharp.Benchmarks/Processing/Resize.cs

@ -215,4 +215,35 @@ namespace SixLabors.ImageSharp.Benchmarks
// SystemDrawing | Core | Core | 3032 | 400 | 118.3 ms | 6.899 ms | 0.3781 ms | 1.00 | 0.00 | - | - | - | 96 B | // SystemDrawing | Core | Core | 3032 | 400 | 118.3 ms | 6.899 ms | 0.3781 ms | 1.00 | 0.00 | - | - | - | 96 B |
// 'ImageSharp, MaxDegreeOfParallelism = 1' | Core | Core | 3032 | 400 | 122.4 ms | 15.069 ms | 0.8260 ms | 1.03 | 0.01 | - | - | - | 15712 B | // 'ImageSharp, MaxDegreeOfParallelism = 1' | Core | Core | 3032 | 400 | 122.4 ms | 15.069 ms | 0.8260 ms | 1.03 | 0.01 | - | - | - | 15712 B |
} }
public class Resize_Bicubic_Compare_Rgba32_Rgb24
{
private Resize_Bicubic_Rgb24 rgb24;
private Resize_Bicubic_Rgba32 rgba32;
[GlobalSetup]
public void Setup()
{
this.rgb24 = new Resize_Bicubic_Rgb24();
this.rgb24.Setup();
this.rgba32 = new Resize_Bicubic_Rgba32();
this.rgba32.Setup();
}
[GlobalCleanup]
public void Cleanup()
{
this.rgb24.Cleanup();
this.rgba32.Cleanup();
}
[Benchmark]
public void SystemDrawing() => this.rgba32.SystemDrawing();
[Benchmark(Baseline = true)]
public void Rgba32() => this.rgba32.ImageSharp_P1();
[Benchmark]
public void Rgb24() => this.rgb24.ImageSharp_P1();
}
} }

102
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs

@ -19,9 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
public class ResizeTests public class ResizeTests
{ {
private const PixelTypes CommonNonDefaultPixelTypes = private const PixelTypes CommonNonDefaultPixelTypes =
PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.RgbaVector; PixelTypes.Rgba32 | PixelTypes.Bgra32 | PixelTypes.Bgr24 | PixelTypes.RgbaVector;
private const PixelTypes DefaultPixelType = PixelTypes.Rgba32;
public static readonly string[] AllResamplerNames = TestUtils.GetAllResamplerNames(); public static readonly string[] AllResamplerNames = TestUtils.GetAllResamplerNames();
@ -188,7 +186,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithTestPatternImages(100, 100, DefaultPixelType)] [WithTestPatternImages(100, 100, PixelTypes.Rgba32)]
public void Resize_Compand<TPixel>(TestImageProvider<TPixel> provider) public void Resize_Compand<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -202,8 +200,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFile(TestImages.Png.Kaboom, DefaultPixelType, false)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32, false)]
[WithFile(TestImages.Png.Kaboom, DefaultPixelType, true)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32, true)]
public void Resize_DoesNotBleedAlphaPixels<TPixel>(TestImageProvider<TPixel> provider, bool compand) public void Resize_DoesNotBleedAlphaPixels<TPixel>(TestImageProvider<TPixel> provider, bool compand)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -217,8 +215,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFile(TestImages.Png.Kaboom, DefaultPixelType, false)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32, false)]
[WithFile(TestImages.Png.Kaboom, DefaultPixelType, true)] [WithFile(TestImages.Png.Kaboom, PixelTypes.Rgba32, true)]
public void Resize_PremultiplyAlpha<TPixel>(TestImageProvider<TPixel> provider, bool premultiplyAlpha) public void Resize_PremultiplyAlpha<TPixel>(TestImageProvider<TPixel> provider, bool premultiplyAlpha)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -243,7 +241,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFile(TestImages.Gif.Giphy, DefaultPixelType)] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)]
public void Resize_IsAppliedToAllFrames<TPixel>(TestImageProvider<TPixel> provider) public void Resize_IsAppliedToAllFrames<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -265,7 +263,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32)]
public void Resize_ThrowsForWrappedMemoryImage<TPixel>(TestImageProvider<TPixel> provider) public void Resize_ThrowsForWrappedMemoryImage<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -283,10 +281,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType, 1)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24, 1)]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType, 4)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24, 4)]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType, 8)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24, 8)]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType, -1)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24, -1)]
public void Resize_WorksWithAllParallelismLevels<TPixel>( public void Resize_WorksWithAllParallelismLevels<TPixel>(
TestImageProvider<TPixel> provider, TestImageProvider<TPixel> provider,
int maxDegreeOfParallelism) int maxDegreeOfParallelism)
@ -305,27 +303,27 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), nameof(AllResamplerNames), DefaultPixelType, 0.5f, null, null)] [WithFileCollection(nameof(CommonTestImages), nameof(AllResamplerNames), PixelTypes.Rgba32 | PixelTypes.Rgb24, 0.5f, null, null)]
[WithFileCollection( [WithFileCollection(
nameof(CommonTestImages), nameof(CommonTestImages),
nameof(SmokeTestResamplerNames), nameof(SmokeTestResamplerNames),
DefaultPixelType, PixelTypes.Rgba32 | PixelTypes.Rgb24,
0.3f, 0.3f,
null, null,
null)] null)]
[WithFileCollection( [WithFileCollection(
nameof(CommonTestImages), nameof(CommonTestImages),
nameof(SmokeTestResamplerNames), nameof(SmokeTestResamplerNames),
DefaultPixelType, PixelTypes.Rgba32 | PixelTypes.Rgb24,
1.8f, 1.8f,
null, null,
null)] null)]
[WithTestPatternImages(nameof(SmokeTestResamplerNames), 100, 100, DefaultPixelType, 0.5f, null, null)] [WithTestPatternImages(nameof(SmokeTestResamplerNames), 100, 100, PixelTypes.Rgba32, 0.5f, null, null)]
[WithTestPatternImages(nameof(SmokeTestResamplerNames), 100, 100, DefaultPixelType, 1f, null, null)] [WithTestPatternImages(nameof(SmokeTestResamplerNames), 100, 100, PixelTypes.Rgba32, 1f, null, null)]
[WithTestPatternImages(nameof(SmokeTestResamplerNames), 50, 50, DefaultPixelType, 8f, null, null)] [WithTestPatternImages(nameof(SmokeTestResamplerNames), 50, 50, PixelTypes.Rgba32, 8f, null, null)]
[WithTestPatternImages(nameof(SmokeTestResamplerNames), 201, 199, DefaultPixelType, null, 100, 99)] [WithTestPatternImages(nameof(SmokeTestResamplerNames), 201, 199, PixelTypes.Rgba32, null, 100, 99)]
[WithTestPatternImages(nameof(SmokeTestResamplerNames), 301, 1180, DefaultPixelType, null, 300, 480)] [WithTestPatternImages(nameof(SmokeTestResamplerNames), 301, 1180, PixelTypes.Rgba32, null, 300, 480)]
[WithTestPatternImages(nameof(SmokeTestResamplerNames), 49, 80, DefaultPixelType, null, 301, 100)] [WithTestPatternImages(nameof(SmokeTestResamplerNames), 49, 80, PixelTypes.Rgba32, null, 301, 100)]
public void Resize_WorksWithAllResamplers<TPixel>( public void Resize_WorksWithAllResamplers<TPixel>(
TestImageProvider<TPixel> provider, TestImageProvider<TPixel> provider,
string samplerName, string samplerName,
@ -382,7 +380,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeFromSourceRectangle<TPixel>(TestImageProvider<TPixel> provider) public void ResizeFromSourceRectangle<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -405,12 +403,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
false)); false));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeHeightAndKeepAspect<TPixel>(TestImageProvider<TPixel> provider) public void ResizeHeightAndKeepAspect<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -419,12 +417,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(0, image.Height / 3, false)); image.Mutate(x => x.Resize(0, image.Height / 3, false));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithTestPatternImages(10, 100, DefaultPixelType)] [WithTestPatternImages(10, 100, PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeHeightCannotKeepAspectKeepsOnePixel<TPixel>(TestImageProvider<TPixel> provider) public void ResizeHeightCannotKeepAspectKeepsOnePixel<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -437,7 +435,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWidthAndKeepAspect<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWidthAndKeepAspect<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -446,12 +444,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(image.Width / 3, 0, false)); image.Mutate(x => x.Resize(image.Width / 3, 0, false));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithTestPatternImages(100, 10, DefaultPixelType)] [WithTestPatternImages(100, 10, PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWidthCannotKeepAspectKeepsOnePixel<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWidthCannotKeepAspectKeepsOnePixel<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -464,7 +462,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWithBoxPadMode<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWithBoxPadMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -479,12 +477,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWithCropHeightMode<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWithCropHeightMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -495,12 +493,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWithCropWidthMode<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWithCropWidthMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -511,12 +509,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFile(TestImages.Jpeg.Issues.IncorrectResize1006, DefaultPixelType)] [WithFile(TestImages.Jpeg.Issues.IncorrectResize1006, PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void CanResizeLargeImageWithCropMode<TPixel>(TestImageProvider<TPixel> provider) public void CanResizeLargeImageWithCropMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -531,12 +529,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWithMaxMode<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWithMaxMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -547,12 +545,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWithMinMode<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWithMinMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -560,21 +558,19 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{ {
var options = new ResizeOptions var options = new ResizeOptions
{ {
Size = new Size( Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)),
(int)Math.Round(image.Width * .75F),
(int)Math.Round(image.Height * .95F)),
Mode = ResizeMode.Min Mode = ResizeMode.Min
}; };
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWithPadMode<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWithPadMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -589,12 +585,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), PixelTypes.Rgba32 | PixelTypes.Rgb24)]
public void ResizeWithStretchMode<TPixel>(TestImageProvider<TPixel> provider) public void ResizeWithStretchMode<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
@ -609,14 +605,14 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
image.Mutate(x => x.Resize(options)); image.Mutate(x => x.Resize(options));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider); image.CompareToReferenceOutput(ValidatorComparer, provider, appendPixelTypeToFileName: false);
} }
} }
[Theory] [Theory]
[WithFile(TestImages.Jpeg.Issues.ExifDecodeOutOfRange694, DefaultPixelType)] [WithFile(TestImages.Jpeg.Issues.ExifDecodeOutOfRange694, PixelTypes.Rgb24)]
[WithFile(TestImages.Jpeg.Issues.ExifGetString750Transform, DefaultPixelType)] [WithFile(TestImages.Jpeg.Issues.ExifGetString750Transform, PixelTypes.Rgb24)]
[WithFile(TestImages.Jpeg.Issues.ExifResize1049, DefaultPixelType)] [WithFile(TestImages.Jpeg.Issues.ExifResize1049, PixelTypes.Rgb24)]
public void CanResizeExifIssueImages<TPixel>(TestImageProvider<TPixel> provider) public void CanResizeExifIssueImages<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {

0
tests/Images/External/ReferenceOutput/ResizeTests/CanResizeLargeImageWithCropMode_Rgba32_issue1006-incorrect-resize.png → tests/Images/External/ReferenceOutput/ResizeTests/CanResizeLargeImageWithCropMode_issue1006-incorrect-resize.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeFromSourceRectangle_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeFromSourceRectangle_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeHeightAndKeepAspect_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeHeightAndKeepAspect_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWidthAndKeepAspect_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWidthAndKeepAspect_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithBoxPadMode_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithBoxPadMode_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithCropHeightMode_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithCropHeightMode_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithCropWidthMode_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithCropWidthMode_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithMaxMode_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithMaxMode_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithMinMode_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithMinMode_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithPadMode_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithPadMode_CalliphoraPartial.png

0
tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithStretchMode_Rgba32_CalliphoraPartial.png → tests/Images/External/ReferenceOutput/ResizeTests/ResizeWithStretchMode_CalliphoraPartial.png

3
tests/Images/External/ReferenceOutput/ResizeTests/Resize_IsNotBoundToSinglePixelType_Bgr24_TestPattern50x50.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4a9940410cca3fe98a6d7aaf0e2184779f908c569a5a34f9965fb3a4f9e6fa8f
size 1066
Loading…
Cancel
Save