mirror of https://github.com/SixLabors/ImageSharp
3 changed files with 18 additions and 9 deletions
@ -1,24 +1,34 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
using SixLabors.ImageSharp.PixelFormats; |
using SixLabors.ImageSharp.PixelFormats; |
||||
using SixLabors.ImageSharp.Processing; |
using SixLabors.ImageSharp.Processing; |
||||
|
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; |
||||
|
using SixLabors.Primitives; |
||||
|
|
||||
using Xunit; |
using Xunit; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms |
||||
{ |
{ |
||||
|
[GroupOutput("Transforms")] |
||||
public class CropTest : FileTestBase |
public class CropTest : FileTestBase |
||||
{ |
{ |
||||
[Theory] |
[Theory] |
||||
[WithFileCollection(nameof(DefaultFiles), DefaultPixelType)] |
[WithTestPatternImages(70, 30, PixelTypes.Rgba32, 0, 0, 70, 30)] |
||||
public void ImageShouldCrop<TPixel>(TestImageProvider<TPixel> provider) |
[WithTestPatternImages(50, 50, PixelTypes.Rgba32, -1, -1, 100, 200)] |
||||
|
[WithTestPatternImages(30, 70, PixelTypes.Rgba32, 7, 13, 20, 50)] |
||||
|
public void Crop<TPixel>(TestImageProvider<TPixel> provider, int x, int y, int w, int h) |
||||
where TPixel : struct, IPixel<TPixel> |
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
using (Image<TPixel> image = provider.GetImage()) |
var rect = new Rectangle(x, y, w, h); |
||||
{ |
FormattableString info = $"X{x}Y{y}.W{w}H{h}"; |
||||
image.Mutate(x => x.Crop(image.Width / 2, image.Height / 2)); |
provider.RunValidatingProcessorTest( |
||||
image.DebugSave(provider); |
ctx => ctx.Crop(rect), |
||||
} |
info, |
||||
|
appendPixelTypeToFileName: false, |
||||
|
comparer: ImageComparer.Exact); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1 +1 @@ |
|||||
Subproject commit 6abc3bc0ac253a24c9e88e68d7b7d853350a85da |
Subproject commit 2841a79efd68d47c6552ce857869eb0d80f8de75 |
||||
Loading…
Reference in new issue