From 1ac655b751409fb58939b5928785f9627b83d9c4 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Wed, 13 Nov 2024 17:43:03 +0100 Subject: [PATCH] Moved Convolve to IMagickImageCreateOperations. --- src/Magick.NET.Core/IMagickImage.cs | 7 ------- src/Magick.NET.Core/IMagickImageCreateOperations.cs | 7 +++++++ src/Magick.NET/MagickImage.CloneMutator.cs | 7 +++++++ src/Magick.NET/MagickImage.cs | 5 ++--- src/Magick.NET/Native/MagickImage.cs | 3 +-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Magick.NET.Core/IMagickImage.cs b/src/Magick.NET.Core/IMagickImage.cs index 4dacfffe79..59df2c8236 100644 --- a/src/Magick.NET.Core/IMagickImage.cs +++ b/src/Magick.NET.Core/IMagickImage.cs @@ -798,13 +798,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl /// Thrown when an error is raised by ImageMagick. IEnumerable ConvexHull(); - /// - /// Convolve image. Applies a user-specified convolution to the image. - /// - /// The convolution matrix. - /// Thrown when an error is raised by ImageMagick. - void Convolve(IConvolveMatrix matrix); - /// /// Copies pixels from the source image to the destination image. /// diff --git a/src/Magick.NET.Core/IMagickImageCreateOperations.cs b/src/Magick.NET.Core/IMagickImageCreateOperations.cs index 1f7f20f649..c3389518f0 100644 --- a/src/Magick.NET.Core/IMagickImageCreateOperations.cs +++ b/src/Magick.NET.Core/IMagickImageCreateOperations.cs @@ -335,6 +335,13 @@ public interface IMagickImageCreateOperations /// Thrown when an error is raised by ImageMagick. void ColorMatrix(IMagickColorMatrix matrix); + /// + /// Convolve image. Applies a user-specified convolution to the image. + /// + /// The convolution matrix. + /// Thrown when an error is raised by ImageMagick. + void Convolve(IConvolveMatrix matrix); + /// /// Resize image to specified size. /// diff --git a/src/Magick.NET/MagickImage.CloneMutator.cs b/src/Magick.NET/MagickImage.CloneMutator.cs index acca06fccc..dda7dca72a 100644 --- a/src/Magick.NET/MagickImage.CloneMutator.cs +++ b/src/Magick.NET/MagickImage.CloneMutator.cs @@ -199,6 +199,13 @@ public void ColorMatrix(IMagickColorMatrix matrix) SetResult(NativeMagickImage.ColorMatrix(matrix)); } + public void Convolve(IConvolveMatrix matrix) + { + Throw.IfNull(nameof(matrix), matrix); + + SetResult(NativeMagickImage.Convolve(matrix)); + } + public void Resize(uint width, uint height) => Resize(new MagickGeometry(width, height)); diff --git a/src/Magick.NET/MagickImage.cs b/src/Magick.NET/MagickImage.cs index 6302879cec..3b05adf2de 100644 --- a/src/Magick.NET/MagickImage.cs +++ b/src/Magick.NET/MagickImage.cs @@ -2341,9 +2341,8 @@ public IEnumerable ConvexHull() /// Thrown when an error is raised by ImageMagick. public void Convolve(IConvolveMatrix matrix) { - Throw.IfNull(nameof(matrix), matrix); - - _nativeInstance.Convolve(matrix); + using var mutator = new Mutator(_nativeInstance); + mutator.Convolve(matrix); } /// diff --git a/src/Magick.NET/Native/MagickImage.cs b/src/Magick.NET/Native/MagickImage.cs index bddeeb8600..6c161c964a 100644 --- a/src/Magick.NET/Native/MagickImage.cs +++ b/src/Magick.NET/Native/MagickImage.cs @@ -347,8 +347,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM public partial IntPtr ConvexHull(out nuint length); [Throws] - [SetInstance] - public partial void Convolve(IDoubleMatrix matrix); + public partial IntPtr Convolve(IDoubleMatrix matrix); [Throws] public partial void CopyPixels(IMagickImage image, MagickRectangle geometry, OffsetInfo offset, Channels channels);