Skip to content

Commit 5740659

Browse files
committed
Moved AddNoise to IMagickImageCreateOperations.
1 parent 015938f commit 5740659

File tree

5 files changed

+61
-38
lines changed

5 files changed

+61
-38
lines changed

src/Magick.NET.Core/IMagickImage.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -253,38 +253,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
253253
/// </summary>
254254
uint Width { get; }
255255

256-
/// <summary>
257-
/// Add noise to image with the specified noise type.
258-
/// </summary>
259-
/// <param name="noiseType">The type of noise that should be added to the image.</param>
260-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
261-
void AddNoise(NoiseType noiseType);
262-
263-
/// <summary>
264-
/// Add noise to the specified channel of the image with the specified noise type.
265-
/// </summary>
266-
/// <param name="noiseType">The type of noise that should be added to the image.</param>
267-
/// <param name="channels">The channel(s) where the noise should be added.</param>
268-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
269-
void AddNoise(NoiseType noiseType, Channels channels);
270-
271-
/// <summary>
272-
/// Add noise to image with the specified noise type.
273-
/// </summary>
274-
/// <param name="noiseType">The type of noise that should be added to the image.</param>
275-
/// <param name="attenuate">Attenuate the random distribution.</param>
276-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
277-
void AddNoise(NoiseType noiseType, double attenuate);
278-
279-
/// <summary>
280-
/// Add noise to the specified channel of the image with the specified noise type.
281-
/// </summary>
282-
/// <param name="noiseType">The type of noise that should be added to the image.</param>
283-
/// <param name="attenuate">Attenuate the random distribution.</param>
284-
/// <param name="channels">The channel(s) where the noise should be added.</param>
285-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
286-
void AddNoise(NoiseType noiseType, double attenuate, Channels channels);
287-
288256
/// <summary>
289257
/// Affine Transform image.
290258
/// </summary>

src/Magick.NET.Core/IMagickImageCreateOperations.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,38 @@ public interface IMagickImageCreateOperations
145145
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
146146
void AdaptiveThreshold(uint width, uint height, Percentage biasPercentage, Channels channels);
147147

148+
/// <summary>
149+
/// Add noise to image with the specified noise type.
150+
/// </summary>
151+
/// <param name="noiseType">The type of noise that should be added to the image.</param>
152+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
153+
void AddNoise(NoiseType noiseType);
154+
155+
/// <summary>
156+
/// Add noise to the specified channel of the image with the specified noise type.
157+
/// </summary>
158+
/// <param name="noiseType">The type of noise that should be added to the image.</param>
159+
/// <param name="channels">The channel(s) where the noise should be added.</param>
160+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
161+
void AddNoise(NoiseType noiseType, Channels channels);
162+
163+
/// <summary>
164+
/// Add noise to image with the specified noise type.
165+
/// </summary>
166+
/// <param name="noiseType">The type of noise that should be added to the image.</param>
167+
/// <param name="attenuate">Attenuate the random distribution.</param>
168+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
169+
void AddNoise(NoiseType noiseType, double attenuate);
170+
171+
/// <summary>
172+
/// Add noise to the specified channel of the image with the specified noise type.
173+
/// </summary>
174+
/// <param name="noiseType">The type of noise that should be added to the image.</param>
175+
/// <param name="attenuate">Attenuate the random distribution.</param>
176+
/// <param name="channels">The channel(s) where the noise should be added.</param>
177+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
178+
void AddNoise(NoiseType noiseType, double attenuate, Channels channels);
179+
148180
/// <summary>
149181
/// Resize image to specified size.
150182
/// <para />

src/Magick.NET/MagickImage.CloneMutator.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ public void AdaptiveThreshold(uint width, uint height, Percentage biasPercentage
7979
public void AdaptiveThreshold(uint width, uint height, Percentage biasPercentage, Channels channels)
8080
=> AdaptiveThreshold(width, height, PercentageHelper.ToQuantum(nameof(biasPercentage), biasPercentage), channels);
8181

82+
public void AddNoise(NoiseType noiseType)
83+
=> AddNoise(noiseType, ImageMagick.Channels.Undefined);
84+
85+
public void AddNoise(NoiseType noiseType, Channels channels)
86+
=> AddNoise(noiseType, 1.0, channels);
87+
88+
public void AddNoise(NoiseType noiseType, double attenuate)
89+
=> AddNoise(noiseType, attenuate, ImageMagick.Channels.Undefined);
90+
91+
public void AddNoise(NoiseType noiseType, double attenuate, Channels channels)
92+
=> SetResult(NativeMagickImage.AddNoise(noiseType, attenuate, channels));
93+
8294
public void Resize(uint width, uint height)
8395
=> Resize(new MagickGeometry(width, height));
8496

src/Magick.NET/MagickImage.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,10 @@ public void AdaptiveThreshold(uint width, uint height, Percentage biasPercentage
11021102
/// <param name="noiseType">The type of noise that should be added to the image.</param>
11031103
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
11041104
public void AddNoise(NoiseType noiseType)
1105-
=> AddNoise(noiseType, ImageMagick.Channels.Undefined);
1105+
{
1106+
using var mutator = new Mutator(_nativeInstance);
1107+
mutator.AddNoise(noiseType);
1108+
}
11061109

11071110
/// <summary>
11081111
/// Add noise to the specified channel of the image with the specified noise type.
@@ -1111,7 +1114,10 @@ public void AddNoise(NoiseType noiseType)
11111114
/// <param name="channels">The channel(s) where the noise should be added.</param>
11121115
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
11131116
public void AddNoise(NoiseType noiseType, Channels channels)
1114-
=> AddNoise(noiseType, 1.0, channels);
1117+
{
1118+
using var mutator = new Mutator(_nativeInstance);
1119+
mutator.AddNoise(noiseType, channels);
1120+
}
11151121

11161122
/// <summary>
11171123
/// Add noise to image with the specified noise type.
@@ -1120,7 +1126,10 @@ public void AddNoise(NoiseType noiseType, Channels channels)
11201126
/// <param name="attenuate">Attenuate the random distribution.</param>
11211127
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
11221128
public void AddNoise(NoiseType noiseType, double attenuate)
1123-
=> AddNoise(noiseType, attenuate, ImageMagick.Channels.Undefined);
1129+
{
1130+
using var mutator = new Mutator(_nativeInstance);
1131+
mutator.AddNoise(noiseType, attenuate);
1132+
}
11241133

11251134
/// <summary>
11261135
/// Add noise to the specified channel of the image with the specified noise type.
@@ -1130,7 +1139,10 @@ public void AddNoise(NoiseType noiseType, double attenuate)
11301139
/// <param name="channels">The channel(s) where the noise should be added.</param>
11311140
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
11321141
public void AddNoise(NoiseType noiseType, double attenuate, Channels channels)
1133-
=> _nativeInstance.AddNoise(noiseType, attenuate, channels);
1142+
{
1143+
using var mutator = new Mutator(_nativeInstance);
1144+
mutator.AddNoise(noiseType, attenuate, channels);
1145+
}
11341146

11351147
/// <summary>
11361148
/// Affine Transform image.

src/Magick.NET/Native/MagickImage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
239239
public partial IntPtr AdaptiveThreshold(nuint width, nuint height, double bias, Channels channels);
240240

241241
[Throws]
242-
[SetInstance]
243-
public partial void AddNoise(NoiseType noiseType, double attenuate, Channels channels);
242+
public partial IntPtr AddNoise(NoiseType noiseType, double attenuate, Channels channels);
244243

245244
[Throws]
246245
[SetInstance]

0 commit comments

Comments
 (0)