mirror of https://github.com/SixLabors/ImageSharp
8 changed files with 131 additions and 156 deletions
@ -0,0 +1,39 @@ |
|||||
|
// <copyright file="RotateFlipTests.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Tests.Processing.Transforms |
||||
|
{ |
||||
|
using ImageSharp.PixelFormats; |
||||
|
using ImageSharp.Processing; |
||||
|
|
||||
|
using Xunit; |
||||
|
|
||||
|
public class RotateFlipTests : FileTestBase |
||||
|
{ |
||||
|
public static readonly string[] FlipFiles = { TestImages.Bmp.F }; |
||||
|
|
||||
|
public static readonly TheoryData<RotateType, FlipType> RotateFlipValues |
||||
|
= new TheoryData<RotateType, FlipType> |
||||
|
{ |
||||
|
{ RotateType.None, FlipType.Vertical }, |
||||
|
{ RotateType.None, FlipType.Horizontal }, |
||||
|
{ RotateType.Rotate90, FlipType.None }, |
||||
|
{ RotateType.Rotate180, FlipType.None }, |
||||
|
{ RotateType.Rotate270, FlipType.None }, |
||||
|
}; |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFileCollection(nameof(FlipFiles), nameof(RotateFlipValues), StandardPixelType)] |
||||
|
public void ImageShouldRotateFlip<TPixel>(TestImageProvider<TPixel> provider, RotateType rotateType, FlipType flipType) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> image = provider.GetImage()) |
||||
|
{ |
||||
|
image.RotateFlip(rotateType, flipType) |
||||
|
.DebugSave(provider, string.Join("_", rotateType, flipType), Extensions.Bmp); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
// <copyright file="RotateTests.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Tests.Processing.Transforms |
||||
|
{ |
||||
|
using ImageSharp.PixelFormats; |
||||
|
using ImageSharp.Processing; |
||||
|
|
||||
|
using Xunit; |
||||
|
|
||||
|
public class RotateTests : FileTestBase |
||||
|
{ |
||||
|
public static readonly TheoryData<float> RotateFloatValues |
||||
|
= new TheoryData<float> |
||||
|
{ |
||||
|
170, |
||||
|
-170 |
||||
|
}; |
||||
|
|
||||
|
public static readonly TheoryData<RotateType> RotateEnumValues |
||||
|
= new TheoryData<RotateType> |
||||
|
{ |
||||
|
RotateType.None, |
||||
|
RotateType.Rotate90, |
||||
|
RotateType.Rotate180, |
||||
|
RotateType.Rotate270 |
||||
|
}; |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFileCollection(nameof(DefaultFiles), nameof(RotateFloatValues), StandardPixelType)] |
||||
|
public void ImageShouldRotate<TPixel>(TestImageProvider<TPixel> provider, float value) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> image = provider.GetImage()) |
||||
|
{ |
||||
|
image.Rotate(value) |
||||
|
.DebugSave(provider, value, Extensions.Bmp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFileCollection(nameof(DefaultFiles), nameof(RotateEnumValues), StandardPixelType)] |
||||
|
public void ImageShouldRotateEnum<TPixel>(TestImageProvider<TPixel> provider, RotateType value) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> image = provider.GetImage()) |
||||
|
{ |
||||
|
image.Rotate(value) |
||||
|
.DebugSave(provider, value, Extensions.Bmp); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
// <copyright file="SkewTest.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Tests.Processing.Transforms |
||||
|
{ |
||||
|
using ImageSharp.PixelFormats; |
||||
|
|
||||
|
using Xunit; |
||||
|
|
||||
|
public class SkewTest : FileTestBase |
||||
|
{ |
||||
|
public static readonly TheoryData<float, float> SkewValues |
||||
|
= new TheoryData<float, float> |
||||
|
{ |
||||
|
{ 20, 10 }, |
||||
|
{ -20, -10 } |
||||
|
}; |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFileCollection(nameof(DefaultFiles), nameof(SkewValues), StandardPixelType)] |
||||
|
public void ImageShouldSkew<TPixel>(TestImageProvider<TPixel> provider, float x, float y) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> image = provider.GetImage()) |
||||
|
{ |
||||
|
image.Skew(x, y) |
||||
|
.DebugSave(provider, string.Join("_", x, y), Extensions.Bmp); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,44 +0,0 @@ |
|||||
// <copyright file="RotateFlipTest.cs" company="James Jackson-South">
|
|
||||
// Copyright (c) James Jackson-South and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
// </copyright>
|
|
||||
|
|
||||
namespace ImageSharp.Tests |
|
||||
{ |
|
||||
using System.IO; |
|
||||
|
|
||||
using ImageSharp.PixelFormats; |
|
||||
|
|
||||
using ImageSharp.Processing; |
|
||||
using Xunit; |
|
||||
|
|
||||
public class RotateFlipTest : FileTestBase |
|
||||
{ |
|
||||
public static readonly TheoryData<RotateType, FlipType> RotateFlipValues |
|
||||
= new TheoryData<RotateType, FlipType> |
|
||||
{ |
|
||||
{ RotateType.None, FlipType.Vertical }, |
|
||||
{ RotateType.None, FlipType.Horizontal }, |
|
||||
{ RotateType.Rotate90, FlipType.None }, |
|
||||
{ RotateType.Rotate180, FlipType.None }, |
|
||||
{ RotateType.Rotate270, FlipType.None }, |
|
||||
}; |
|
||||
|
|
||||
[Theory] |
|
||||
[MemberData(nameof(RotateFlipValues))] |
|
||||
public void ImageShouldRotateFlip(RotateType rotateType, FlipType flipType) |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("RotateFlip"); |
|
||||
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
string filename = file.GetFileName(rotateType + "-" + flipType); |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
||||
{ |
|
||||
image.RotateFlip(rotateType, flipType).Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,67 +0,0 @@ |
|||||
// <copyright file="RotateTest.cs" company="James Jackson-South">
|
|
||||
// Copyright (c) James Jackson-South and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
// </copyright>
|
|
||||
|
|
||||
namespace ImageSharp.Tests |
|
||||
{ |
|
||||
using System.IO; |
|
||||
|
|
||||
using ImageSharp.PixelFormats; |
|
||||
|
|
||||
using ImageSharp.Processing; |
|
||||
using Xunit; |
|
||||
|
|
||||
public class RotateTest : FileTestBase |
|
||||
{ |
|
||||
public static readonly TheoryData<float> RotateFloatValues |
|
||||
= new TheoryData<float> |
|
||||
{ |
|
||||
170 , |
|
||||
-170 , |
|
||||
}; |
|
||||
|
|
||||
public static readonly TheoryData<RotateType> RotateEnumValues |
|
||||
= new TheoryData<RotateType> |
|
||||
{ |
|
||||
RotateType.None, |
|
||||
RotateType.Rotate90, |
|
||||
RotateType.Rotate180, |
|
||||
RotateType.Rotate270 |
|
||||
}; |
|
||||
|
|
||||
[Theory] |
|
||||
[MemberData(nameof(RotateFloatValues))] |
|
||||
public void ImageShouldApplyRotateSampler(float value) |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("Rotate"); |
|
||||
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
string filename = file.GetFileName(value); |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
||||
{ |
|
||||
image.Rotate(value).Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
[Theory] |
|
||||
[MemberData(nameof(RotateEnumValues))] |
|
||||
public void ImageShouldApplyRotateSampler(RotateType value) |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("Rotate"); |
|
||||
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
string filename = file.GetFileName(value); |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
||||
{ |
|
||||
image.Rotate(value).Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,42 +0,0 @@ |
|||||
// <copyright file="SkewTest.cs" company="James Jackson-South">
|
|
||||
// Copyright (c) James Jackson-South and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
// </copyright>
|
|
||||
|
|
||||
namespace ImageSharp.Tests |
|
||||
{ |
|
||||
using System.IO; |
|
||||
|
|
||||
using ImageSharp.PixelFormats; |
|
||||
|
|
||||
using Xunit; |
|
||||
|
|
||||
public class SkewTest : FileTestBase |
|
||||
{ |
|
||||
public static readonly TheoryData<float, float> SkewValues |
|
||||
= new TheoryData<float, float> |
|
||||
{ |
|
||||
{ 20, 10 }, |
|
||||
{ -20, -10 } |
|
||||
}; |
|
||||
|
|
||||
[Theory] |
|
||||
[MemberData(nameof(SkewValues))] |
|
||||
public void ImageShouldApplySkewSampler(float x, float y) |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("Skew"); |
|
||||
|
|
||||
// Matches live example
|
|
||||
// http://www.w3schools.com/css/tryit.asp?filename=trycss3_transform_skew
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
string filename = file.GetFileName(x + "-" + y); |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
||||
{ |
|
||||
image.Skew(x, y).Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue