@@ -21,6 +21,10 @@ public static class ProcessingExtensions
2121 /// <param name="operation">The operation to perform on the source.</param>
2222 public static void Mutate ( this Image source , Action < IImageProcessingContext > operation )
2323 {
24+ Guard . NotNull ( source , nameof ( source ) ) ;
25+ Guard . NotNull ( operation , nameof ( operation ) ) ;
26+ source . EnsureNotDisposed ( ) ;
27+
2428 ProcessingVisitor visitor = new ProcessingVisitor ( operation , true ) ;
2529 source . AcceptVisitor ( visitor ) ;
2630 }
@@ -34,8 +38,9 @@ public static void Mutate(this Image source, Action<IImageProcessingContext> ope
3438 public static void Mutate < TPixel > ( this Image < TPixel > source , Action < IImageProcessingContext > operation )
3539 where TPixel : struct , IPixel < TPixel >
3640 {
37- Guard . NotNull ( operation , nameof ( operation ) ) ;
3841 Guard . NotNull ( source , nameof ( source ) ) ;
42+ Guard . NotNull ( operation , nameof ( operation ) ) ;
43+ source . EnsureNotDisposed ( ) ;
3944
4045 IInternalImageProcessingContext < TPixel > operationsRunner = source . GetConfiguration ( ) . ImageOperationsProvider
4146 . CreateImageProcessingContext ( source , true ) ;
@@ -51,8 +56,9 @@ public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageProces
5156 public static void Mutate < TPixel > ( this Image < TPixel > source , params IImageProcessor [ ] operations )
5257 where TPixel : struct , IPixel < TPixel >
5358 {
54- Guard . NotNull ( operations , nameof ( operations ) ) ;
5559 Guard . NotNull ( source , nameof ( source ) ) ;
60+ Guard . NotNull ( operations , nameof ( operations ) ) ;
61+ source . EnsureNotDisposed ( ) ;
5662
5763 IInternalImageProcessingContext < TPixel > operationsRunner = source . GetConfiguration ( ) . ImageOperationsProvider
5864 . CreateImageProcessingContext ( source , true ) ;
@@ -67,6 +73,10 @@ public static void Mutate<TPixel>(this Image<TPixel> source, params IImageProces
6773 /// <returns>The new <see cref="SixLabors.ImageSharp.Image"/>.</returns>
6874 public static Image Clone ( this Image source , Action < IImageProcessingContext > operation )
6975 {
76+ Guard . NotNull ( source , nameof ( source ) ) ;
77+ Guard . NotNull ( operation , nameof ( operation ) ) ;
78+ source . EnsureNotDisposed ( ) ;
79+
7080 ProcessingVisitor visitor = new ProcessingVisitor ( operation , false ) ;
7181 source . AcceptVisitor ( visitor ) ;
7282 return visitor . ResultImage ;
@@ -82,8 +92,9 @@ public static Image Clone(this Image source, Action<IImageProcessingContext> ope
8292 public static Image < TPixel > Clone < TPixel > ( this Image < TPixel > source , Action < IImageProcessingContext > operation )
8393 where TPixel : struct , IPixel < TPixel >
8494 {
85- Guard . NotNull ( operation , nameof ( operation ) ) ;
8695 Guard . NotNull ( source , nameof ( source ) ) ;
96+ Guard . NotNull ( operation , nameof ( operation ) ) ;
97+ source . EnsureNotDisposed ( ) ;
8798
8899 IInternalImageProcessingContext < TPixel > operationsRunner = source . GetConfiguration ( ) . ImageOperationsProvider
89100 . CreateImageProcessingContext ( source , false ) ;
@@ -101,8 +112,9 @@ public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IIma
101112 public static Image < TPixel > Clone < TPixel > ( this Image < TPixel > source , params IImageProcessor [ ] operations )
102113 where TPixel : struct , IPixel < TPixel >
103114 {
104- Guard . NotNull ( operations , nameof ( operations ) ) ;
105115 Guard . NotNull ( source , nameof ( source ) ) ;
116+ Guard . NotNull ( operations , nameof ( operations ) ) ;
117+ source . EnsureNotDisposed ( ) ;
106118
107119 IInternalImageProcessingContext < TPixel > operationsRunner = source . GetConfiguration ( ) . ImageOperationsProvider
108120 . CreateImageProcessingContext ( source , false ) ;
@@ -152,4 +164,4 @@ public void Visit<TPixel>(Image<TPixel> image)
152164 }
153165 }
154166 }
155- }
167+ }
0 commit comments