Skip to content

Commit a726c59

Browse files
committed
测试多线程处置的方法
1 parent ea490c2 commit a726c59

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
using DotNetCampus.MediaConverters.Imaging.Effect;
1+
using System.Numerics;
2+
3+
using DotNetCampus.MediaConverters.Imaging.Effect;
4+
25
using SixLabors.ImageSharp;
36
using SixLabors.ImageSharp.PixelFormats;
7+
using SixLabors.ImageSharp.Processing;
48

59
namespace DotNetCampus.MediaConverters.Tests.Imaging.Effect;
610

@@ -10,14 +14,35 @@ public class SoftEdgeHelperTests
1014
[TestMethod()]
1115
public void SetSoftEdgeMaskTest()
1216
{
13-
Image<Rgba32> bitmap = TestFileProvider.GetDefaultTestImage();
14-
var alphaRepresentation = bitmap.PixelType.AlphaRepresentation;
17+
Image<Rgba32> image = TestFileProvider.GetDefaultTestImage();
1518

16-
SoftEdgeHelper.SetSoftEdgeMask(bitmap, 50.0f);
19+
SoftEdgeHelper.SetSoftEdgeMask(image, 50.0f);
1720

18-
var file = bitmap.SaveAsTestImageFile();
21+
var file = image.SaveAsTestImageFile();
1922

2023
Assert.IsTrue(File.Exists(file));
2124
TestHelper.OpenFileInExplorer(file);
2225
}
26+
27+
[TestMethod()]
28+
public void TestManipulation()
29+
{
30+
Image<Rgba32> image = TestFileProvider.GetDefaultTestImage();
31+
image.Mutate(c => c.ProcessPixelRowsAsVector4(row =>
32+
{
33+
for (int col = 0; col < row.Length; col++)
34+
{
35+
// We can apply any custom processing logic here
36+
ref var pixel = ref row[col];
37+
pixel = Vector4.SquareRoot(pixel);
38+
if (col < row.Length - 1)
39+
{
40+
pixel = pixel * (1 + Vector4.DistanceSquared(pixel, row[col + 1]/100));
41+
}
42+
}
43+
}));
44+
45+
var file = image.SaveAsTestImageFile();
46+
TestHelper.OpenFileInExplorer(file);
47+
}
2348
}

0 commit comments

Comments
 (0)