1
- using DotNetCampus . MediaConverters . Imaging . Effect ;
1
+ using System . Numerics ;
2
+
3
+ using DotNetCampus . MediaConverters . Imaging . Effect ;
4
+
2
5
using SixLabors . ImageSharp ;
3
6
using SixLabors . ImageSharp . PixelFormats ;
7
+ using SixLabors . ImageSharp . Processing ;
4
8
5
9
namespace DotNetCampus . MediaConverters . Tests . Imaging . Effect ;
6
10
@@ -10,14 +14,35 @@ public class SoftEdgeHelperTests
10
14
[ TestMethod ( ) ]
11
15
public void SetSoftEdgeMaskTest ( )
12
16
{
13
- Image < Rgba32 > bitmap = TestFileProvider . GetDefaultTestImage ( ) ;
14
- var alphaRepresentation = bitmap . PixelType . AlphaRepresentation ;
17
+ Image < Rgba32 > image = TestFileProvider . GetDefaultTestImage ( ) ;
15
18
16
- SoftEdgeHelper . SetSoftEdgeMask ( bitmap , 50.0f ) ;
19
+ SoftEdgeHelper . SetSoftEdgeMask ( image , 50.0f ) ;
17
20
18
- var file = bitmap . SaveAsTestImageFile ( ) ;
21
+ var file = image . SaveAsTestImageFile ( ) ;
19
22
20
23
Assert . IsTrue ( File . Exists ( file ) ) ;
21
24
TestHelper . OpenFileInExplorer ( file ) ;
22
25
}
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
+ }
23
48
}
0 commit comments