Skip to content

Commit 3b69e25

Browse files
committed
Moved AdaptiveResize to IMagickImageCreateOperations.
1 parent df7e9dd commit 3b69e25

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

src/Magick.NET.Core/IMagickImage.cs

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

256-
/// <summary>
257-
/// Resize using mesh interpolation. It works well for small resizes of less than +/- 50%
258-
/// of the original image size. For larger resizing on images a full filtered and slower resize
259-
/// function should be used instead.
260-
/// <para />
261-
/// Resize will fit the image into the requested size. It does NOT fill, the requested box size.
262-
/// Use the <see cref="IMagickGeometry"/> overload for more control over the resulting size.
263-
/// </summary>
264-
/// <param name="width">The new width.</param>
265-
/// <param name="height">The new height.</param>
266-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
267-
void AdaptiveResize(uint width, uint height);
268-
269-
/// <summary>
270-
/// Resize using mesh interpolation. It works well for small resizes of less than +/- 50%
271-
/// of the original image size. For larger resizing on images a full filtered and slower resize
272-
/// function should be used instead.
273-
/// </summary>
274-
/// <param name="geometry">The geometry to use.</param>
275-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
276-
void AdaptiveResize(IMagickGeometry geometry);
277-
278256
/// <summary>
279257
/// Adaptively sharpens the image by sharpening more intensely near image edges and less
280258
/// intensely far from edges.

src/Magick.NET.Core/IMagickImageCreateOperations.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@ public interface IMagickImageCreateOperations
2929
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
3030
void AdaptiveBlur(double radius, double sigma);
3131

32+
/// <summary>
33+
/// Resize using mesh interpolation. It works well for small resizes of less than +/- 50%
34+
/// of the original image size. For larger resizing on images a full filtered and slower resize
35+
/// function should be used instead.
36+
/// <para />
37+
/// Resize will fit the image into the requested size. It does NOT fill, the requested box size.
38+
/// Use the <see cref="IMagickGeometry"/> overload for more control over the resulting size.
39+
/// </summary>
40+
/// <param name="width">The new width.</param>
41+
/// <param name="height">The new height.</param>
42+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
43+
void AdaptiveResize(uint width, uint height);
44+
45+
/// <summary>
46+
/// Resize using mesh interpolation. It works well for small resizes of less than +/- 50%
47+
/// of the original image size. For larger resizing on images a full filtered and slower resize
48+
/// function should be used instead.
49+
/// </summary>
50+
/// <param name="geometry">The geometry to use.</param>
51+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
52+
void AdaptiveResize(IMagickGeometry geometry);
53+
3254
/// <summary>
3355
/// Resize image to specified size.
3456
/// <para />

src/Magick.NET/MagickImage.CloneMutator.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ public void AdaptiveBlur(double radius)
3939
public void AdaptiveBlur(double radius, double sigma)
4040
=> SetResult(NativeMagickImage.AdaptiveBlur(radius, sigma));
4141

42+
public void AdaptiveResize(uint width, uint height)
43+
=> AdaptiveResize(new MagickGeometry(width, height));
44+
45+
public void AdaptiveResize(IMagickGeometry geometry)
46+
{
47+
Throw.IfNull(nameof(geometry), geometry);
48+
49+
SetResult(NativeMagickImage.AdaptiveResize(geometry.ToString()));
50+
}
51+
4252
public void Resize(uint width, uint height)
4353
=> Resize(new MagickGeometry(width, height));
4454

src/Magick.NET/MagickImage.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,10 @@ public void AdaptiveBlur(double radius, double sigma)
944944
/// <param name="height">The new height.</param>
945945
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
946946
public void AdaptiveResize(uint width, uint height)
947-
=> AdaptiveResize(new MagickGeometry(width, height));
947+
{
948+
using var mutator = new Mutator(_nativeInstance);
949+
mutator.AdaptiveResize(width, height);
950+
}
948951

949952
/// <summary>
950953
/// Resize using mesh interpolation. It works well for small resizes of less than +/- 50%
@@ -955,9 +958,8 @@ public void AdaptiveResize(uint width, uint height)
955958
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
956959
public void AdaptiveResize(IMagickGeometry geometry)
957960
{
958-
Throw.IfNull(nameof(geometry), geometry);
959-
960-
_nativeInstance.AdaptiveResize(geometry.ToString());
961+
using var mutator = new Mutator(_nativeInstance);
962+
mutator.AdaptiveResize(geometry);
961963
}
962964

963965
/// <summary>

src/Magick.NET/Native/MagickImage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
230230
public partial IntPtr AdaptiveBlur(double radius, double sigma);
231231

232232
[Throws]
233-
[SetInstance]
234-
public partial void AdaptiveResize(string geometry);
233+
public partial IntPtr AdaptiveResize(string geometry);
235234

236235
[Throws]
237236
[SetInstance]

0 commit comments

Comments
 (0)