Skip to content

Commit 93223aa

Browse files
committed
Moved Distort to IMagickImageCreateOperations.
1 parent 0a31f09 commit 93223aa

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

src/Magick.NET.Core/IMagickImage.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -891,25 +891,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
891891
/// <returns>The color type of the image.</returns>
892892
ColorType DetermineColorType();
893893

894-
/// <summary>
895-
/// Distorts an image using various distortion methods, by mapping color lookups of the source
896-
/// image to a new destination image of the same size as the source image.
897-
/// </summary>
898-
/// <param name="method">The distortion method to use.</param>
899-
/// <param name="arguments">An array containing the arguments for the distortion.</param>
900-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
901-
void Distort(DistortMethod method, params double[] arguments);
902-
903-
/// <summary>
904-
/// Distorts an image using various distortion methods, by mapping color lookups of the source
905-
/// image to a new destination image usually of the same size as the source image, unless
906-
/// 'bestfit' is set to true.
907-
/// </summary>
908-
/// <param name="settings">The settings for the distort operation.</param>
909-
/// <param name="arguments">An array containing the arguments for the distortion.</param>
910-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
911-
void Distort(IDistortSettings settings, params double[] arguments);
912-
913894
/// <summary>
914895
/// Draw on image using one or more drawables.
915896
/// </summary>

src/Magick.NET.Core/IMagickImageCreateOperations.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,25 @@ public interface IMagickImageCreateOperations
406406
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
407407
void Despeckle();
408408

409+
/// <summary>
410+
/// Distorts an image using various distortion methods, by mapping color lookups of the source
411+
/// image to a new destination image of the same size as the source image.
412+
/// </summary>
413+
/// <param name="method">The distortion method to use.</param>
414+
/// <param name="arguments">An array containing the arguments for the distortion.</param>
415+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
416+
void Distort(DistortMethod method, params double[] arguments);
417+
418+
/// <summary>
419+
/// Distorts an image using various distortion methods, by mapping color lookups of the source
420+
/// image to a new destination image usually of the same size as the source image, unless
421+
/// 'bestfit' is set to true.
422+
/// </summary>
423+
/// <param name="settings">The settings for the distort operation.</param>
424+
/// <param name="arguments">An array containing the arguments for the distortion.</param>
425+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
426+
void Distort(IDistortSettings settings, params double[] arguments);
427+
409428
/// <summary>
410429
/// Resize image to specified size.
411430
/// <para />

src/Magick.NET/MagickImage.CloneMutator.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,21 @@ public double DeskewAndCrop(Percentage threshold)
231231
public void Despeckle()
232232
=> SetResult(NativeMagickImage.Despeckle());
233233

234+
public void Distort(DistortMethod method, params double[] arguments)
235+
=> Distort(new DistortSettings(method), arguments);
236+
237+
public void Distort(IDistortSettings settings, params double[] arguments)
238+
{
239+
Throw.IfNull(nameof(settings), settings);
240+
Throw.IfNullOrEmpty(nameof(arguments), arguments);
241+
242+
using var temporaryDefines = new TemporaryDefines(NativeMagickImage);
243+
temporaryDefines.SetArtifact("distort:scale", settings.Scale);
244+
temporaryDefines.SetArtifact("distort:viewport", settings.Viewport);
245+
246+
SetResult(NativeMagickImage.Distort(settings.Method, settings.Bestfit, arguments, (nuint)arguments.Length));
247+
}
248+
234249
public void Resize(uint width, uint height)
235250
=> Resize(new MagickGeometry(width, height));
236251

src/Magick.NET/MagickImage.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,10 @@ public void Dispose()
25942594
/// <param name="arguments">An array containing the arguments for the distortion.</param>
25952595
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
25962596
public void Distort(DistortMethod method, params double[] arguments)
2597-
=> Distort(new DistortSettings(method), arguments);
2597+
{
2598+
using var mutator = new Mutator(_nativeInstance);
2599+
mutator.Distort(new DistortSettings(method), arguments);
2600+
}
25982601

25992602
/// <summary>
26002603
/// Distorts an image using various distortion methods, by mapping color lookups of the source
@@ -2606,14 +2609,8 @@ public void Distort(DistortMethod method, params double[] arguments)
26062609
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
26072610
public void Distort(IDistortSettings settings, params double[] arguments)
26082611
{
2609-
Throw.IfNull(nameof(settings), settings);
2610-
Throw.IfNullOrEmpty(nameof(arguments), arguments);
2611-
2612-
using var temporaryDefines = new TemporaryDefines(this);
2613-
temporaryDefines.SetArtifact("distort:scale", settings.Scale);
2614-
temporaryDefines.SetArtifact("distort:viewport", settings.Viewport);
2615-
2616-
_nativeInstance.Distort(settings.Method, settings.Bestfit, arguments, (nuint)arguments.Length);
2612+
using var mutator = new Mutator(_nativeInstance);
2613+
mutator.Distort(settings, arguments);
26172614
}
26182615

26192616
/// <summary>

src/Magick.NET/Native/MagickImage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
377377
public partial ColorType DetermineColorType();
378378

379379
[Throws]
380-
[SetInstance]
381-
public partial void Distort(DistortMethod method, bool bestfit, double[] arguments, nuint length);
380+
public partial IntPtr Distort(DistortMethod method, bool bestfit, double[] arguments, nuint length);
382381

383382
[Throws]
384383
[SetInstance]

0 commit comments

Comments
 (0)