Skip to content

Commit d3c1bbe

Browse files
committed
Moved Border to IMagickImageCreateOperations.
1 parent cd37fe7 commit d3c1bbe

File tree

5 files changed

+45
-28
lines changed

5 files changed

+45
-28
lines changed

src/Magick.NET.Core/IMagickImage.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -348,28 +348,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
348348
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
349349
void BlackThreshold(Percentage threshold, Channels channels);
350350

351-
/// <summary>
352-
/// Add a border to the image.
353-
/// </summary>
354-
/// <param name="size">The size of the border.</param>
355-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
356-
void Border(uint size);
357-
358-
/// <summary>
359-
/// Add a border to the image.
360-
/// </summary>
361-
/// <param name="width">The width of the border.</param>
362-
/// <param name="height">The height of the border.</param>
363-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
364-
void Border(uint width, uint height);
365-
366-
/// <summary>
367-
/// Add a border to the image.
368-
/// </summary>
369-
/// <param name="percentage">The size of the border.</param>
370-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
371-
void Border(Percentage percentage);
372-
373351
/// <summary>
374352
/// Changes the brightness and/or contrast of an image. It converts the brightness and
375353
/// contrast parameters into slope and intercept and calls a polynomical function to apply

src/Magick.NET.Core/IMagickImageCreateOperations.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,28 @@ public interface IMagickImageCreateOperations
253253
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
254254
void Blur(double radius, double sigma, Channels channels);
255255

256+
/// <summary>
257+
/// Add a border to the image.
258+
/// </summary>
259+
/// <param name="size">The size of the border.</param>
260+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
261+
void Border(uint size);
262+
263+
/// <summary>
264+
/// Add a border to the image.
265+
/// </summary>
266+
/// <param name="width">The width of the border.</param>
267+
/// <param name="height">The height of the border.</param>
268+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
269+
void Border(uint width, uint height);
270+
271+
/// <summary>
272+
/// Add a border to the image.
273+
/// </summary>
274+
/// <param name="percentage">The size of the border.</param>
275+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
276+
void Border(Percentage percentage);
277+
256278
/// <summary>
257279
/// Resize image to specified size.
258280
/// <para />

src/Magick.NET/MagickImage.CloneMutator.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ public void Blur(double radius, double sigma)
129129
public void Blur(double radius, double sigma, Channels channels)
130130
=> SetResult(NativeMagickImage.Blur(radius, sigma, channels));
131131

132+
public void Border(uint size)
133+
=> Border(size, size);
134+
135+
public void Border(uint width, uint height)
136+
{
137+
var rectangle = new MagickRectangle(0, 0, width, height);
138+
SetResult(NativeMagickImage.Border(rectangle));
139+
}
140+
141+
public void Border(Percentage percentage)
142+
=> Border((uint)(NativeMagickImage.Width_Get() * percentage), (uint)(NativeMagickImage.Height_Get() * percentage));
143+
132144
public void Resize(uint width, uint height)
133145
=> Resize(new MagickGeometry(width, height));
134146

src/Magick.NET/MagickImage.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,10 @@ public void Blur(double radius, double sigma, Channels channels)
13841384
/// <param name="size">The size of the border.</param>
13851385
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
13861386
public void Border(uint size)
1387-
=> Border(size, size);
1387+
{
1388+
using var mutator = new Mutator(_nativeInstance);
1389+
mutator.Border(size);
1390+
}
13881391

13891392
/// <summary>
13901393
/// Add a border to the image.
@@ -1394,8 +1397,8 @@ public void Border(uint size)
13941397
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
13951398
public void Border(uint width, uint height)
13961399
{
1397-
var rectangle = new MagickRectangle(0, 0, width, height);
1398-
_nativeInstance.Border(rectangle);
1400+
using var mutator = new Mutator(_nativeInstance);
1401+
mutator.Border(width, height);
13991402
}
14001403

14011404
/// <summary>
@@ -1404,7 +1407,10 @@ public void Border(uint width, uint height)
14041407
/// <param name="percentage">The size of the border.</param>
14051408
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
14061409
public void Border(Percentage percentage)
1407-
=> Border((uint)(Width * percentage), (uint)(Height * percentage));
1410+
{
1411+
using var mutator = new Mutator(_nativeInstance);
1412+
mutator.Border(percentage);
1413+
}
14081414

14091415
/// <summary>
14101416
/// Changes the brightness and/or contrast of an image. It converts the brightness and

src/Magick.NET/Native/MagickImage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
275275
public partial IntPtr Blur(double radius, double sigma, Channels channels);
276276

277277
[Throws]
278-
[SetInstance]
279-
public partial void Border(MagickRectangle value);
278+
public partial IntPtr Border(MagickRectangle value);
280279

281280
[Throws]
282281
public partial void BrightnessContrast(double brightness, double contrast, Channels channels);

0 commit comments

Comments
 (0)