Skip to content

Commit 8f5e970

Browse files
committed
Moved Extent to IMagickImageCreateOperations.
1 parent 2350b3a commit 8f5e970

File tree

7 files changed

+163
-97
lines changed

7 files changed

+163
-97
lines changed

src/Magick.NET.Core/IMagickImage.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -965,48 +965,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
965965
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
966966
void Evaluate(Channels channels, IMagickGeometry geometry, EvaluateOperator evaluateOperator, Percentage percentage);
967967

968-
/// <summary>
969-
/// Extend the image as defined by the width and height.
970-
/// </summary>
971-
/// <param name="width">The width to extend the image to.</param>
972-
/// <param name="height">The height to extend the image to.</param>
973-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
974-
void Extent(uint width, uint height);
975-
976-
/// <summary>
977-
/// Extend the image as defined by the width and height.
978-
/// </summary>
979-
/// <param name="x">The X offset from origin.</param>
980-
/// <param name="y">The Y offset from origin.</param>
981-
/// <param name="width">The width to extend the image to.</param>
982-
/// <param name="height">The height to extend the image to.</param>
983-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
984-
void Extent(int x, int y, uint width, uint height);
985-
986-
/// <summary>
987-
/// Extend the image as defined by the width and height.
988-
/// </summary>
989-
/// <param name="width">The width to extend the image to.</param>
990-
/// <param name="height">The height to extend the image to.</param>
991-
/// <param name="gravity">The placement gravity.</param>
992-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
993-
void Extent(uint width, uint height, Gravity gravity);
994-
995-
/// <summary>
996-
/// Extend the image as defined by the rectangle.
997-
/// </summary>
998-
/// <param name="geometry">The geometry to extend the image to.</param>
999-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
1000-
void Extent(IMagickGeometry geometry);
1001-
1002-
/// <summary>
1003-
/// Extend the image as defined by the geometry.
1004-
/// </summary>
1005-
/// <param name="geometry">The geometry to extend the image to.</param>
1006-
/// <param name="gravity">The placement gravity.</param>
1007-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
1008-
void Extent(IMagickGeometry geometry, Gravity gravity);
1009-
1010968
/// <summary>
1011969
/// Flip image (reflect each scanline in the vertical direction).
1012970
/// </summary>

src/Magick.NET.Core/IMagickImageCloneMutator{TQuantumType}.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,40 @@ public interface IMagickImageCloneMutator<TQuantumType> : IMagickImageCreateOper
3030
/// <param name="alphaBlue">The alpha percentage for blue.</param>
3131
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
3232
void Colorize(IMagickColor<TQuantumType> color, Percentage alphaRed, Percentage alphaGreen, Percentage alphaBlue);
33+
34+
/// <summary>
35+
/// Extend the image as defined by the width and height.
36+
/// </summary>
37+
/// <param name="width">The width to extend the image to.</param>
38+
/// <param name="height">The height to extend the image to.</param>
39+
/// <param name="backgroundColor">The background color to use.</param>
40+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
41+
void Extent(uint width, uint height, IMagickColor<TQuantumType> backgroundColor);
42+
43+
/// <summary>
44+
/// Extend the image as defined by the width and height.
45+
/// </summary>
46+
/// <param name="width">The width to extend the image to.</param>
47+
/// <param name="height">The height to extend the image to.</param>
48+
/// <param name="gravity">The placement gravity.</param>
49+
/// <param name="backgroundColor">The background color to use.</param>
50+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
51+
void Extent(uint width, uint height, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);
52+
53+
/// <summary>
54+
/// Extend the image as defined by the geometry.
55+
/// </summary>
56+
/// <param name="geometry">The geometry to extend the image to.</param>
57+
/// <param name="backgroundColor">The background color to use.</param>
58+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
59+
void Extent(IMagickGeometry geometry, IMagickColor<TQuantumType> backgroundColor);
60+
61+
/// <summary>
62+
/// Extend the image as defined by the geometry.
63+
/// </summary>
64+
/// <param name="geometry">The geometry to extend the image to.</param>
65+
/// <param name="gravity">The placement gravity.</param>
66+
/// <param name="backgroundColor">The background color to use.</param>
67+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
68+
void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);
3369
}

src/Magick.NET.Core/IMagickImageCreateOperations.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,48 @@ public interface IMagickImageCreateOperations
459459
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
460460
void Enhance();
461461

462+
/// <summary>
463+
/// Extend the image as defined by the width and height.
464+
/// </summary>
465+
/// <param name="width">The width to extend the image to.</param>
466+
/// <param name="height">The height to extend the image to.</param>
467+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
468+
void Extent(uint width, uint height);
469+
470+
/// <summary>
471+
/// Extend the image as defined by the width and height.
472+
/// </summary>
473+
/// <param name="x">The X offset from origin.</param>
474+
/// <param name="y">The Y offset from origin.</param>
475+
/// <param name="width">The width to extend the image to.</param>
476+
/// <param name="height">The height to extend the image to.</param>
477+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
478+
void Extent(int x, int y, uint width, uint height);
479+
480+
/// <summary>
481+
/// Extend the image as defined by the width and height.
482+
/// </summary>
483+
/// <param name="width">The width to extend the image to.</param>
484+
/// <param name="height">The height to extend the image to.</param>
485+
/// <param name="gravity">The placement gravity.</param>
486+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
487+
void Extent(uint width, uint height, Gravity gravity);
488+
489+
/// <summary>
490+
/// Extend the image as defined by the rectangle.
491+
/// </summary>
492+
/// <param name="geometry">The geometry to extend the image to.</param>
493+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
494+
void Extent(IMagickGeometry geometry);
495+
496+
/// <summary>
497+
/// Extend the image as defined by the geometry.
498+
/// </summary>
499+
/// <param name="geometry">The geometry to extend the image to.</param>
500+
/// <param name="gravity">The placement gravity.</param>
501+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
502+
void Extent(IMagickGeometry geometry, Gravity gravity);
503+
462504
/// <summary>
463505
/// Resize image to specified size.
464506
/// <para />

src/Magick.NET.Core/IMagickImage{TQuantumType}.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -201,42 +201,6 @@ public partial interface IMagickImage<TQuantumType> : IMagickImage, IComparable<
201201
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
202202
void Draw(IDrawables<TQuantumType> drawables);
203203

204-
/// <summary>
205-
/// Extend the image as defined by the width and height.
206-
/// </summary>
207-
/// <param name="width">The width to extend the image to.</param>
208-
/// <param name="height">The height to extend the image to.</param>
209-
/// <param name="backgroundColor">The background color to use.</param>
210-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
211-
void Extent(uint width, uint height, IMagickColor<TQuantumType> backgroundColor);
212-
213-
/// <summary>
214-
/// Extend the image as defined by the width and height.
215-
/// </summary>
216-
/// <param name="width">The width to extend the image to.</param>
217-
/// <param name="height">The height to extend the image to.</param>
218-
/// <param name="gravity">The placement gravity.</param>
219-
/// <param name="backgroundColor">The background color to use.</param>
220-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
221-
void Extent(uint width, uint height, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);
222-
223-
/// <summary>
224-
/// Extend the image as defined by the geometry.
225-
/// </summary>
226-
/// <param name="geometry">The geometry to extend the image to.</param>
227-
/// <param name="backgroundColor">The background color to use.</param>
228-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
229-
void Extent(IMagickGeometry geometry, IMagickColor<TQuantumType> backgroundColor);
230-
231-
/// <summary>
232-
/// Extend the image as defined by the geometry.
233-
/// </summary>
234-
/// <param name="geometry">The geometry to extend the image to.</param>
235-
/// <param name="gravity">The placement gravity.</param>
236-
/// <param name="backgroundColor">The background color to use.</param>
237-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
238-
void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);
239-
240204
/// <summary>
241205
/// Floodfill pixels matching color (within fuzz factor) of target pixel(x,y) with replacement
242206
/// alpha value using method.

src/Magick.NET/MagickImage.CloneMutator.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,60 @@ public void Encipher(string passphrase)
265265
public void Enhance()
266266
=> SetResult(NativeMagickImage.Enhance());
267267

268+
public void Extent(uint width, uint height)
269+
=> Extent(new MagickGeometry(width, height));
270+
271+
public void Extent(int x, int y, uint width, uint height)
272+
=> Extent(new MagickGeometry(x, y, width, height));
273+
274+
public void Extent(uint width, uint height, IMagickColor<QuantumType> backgroundColor)
275+
=> Extent(new MagickGeometry(width, height), backgroundColor);
276+
277+
public void Extent(uint width, uint height, Gravity gravity)
278+
=> Extent(new MagickGeometry(width, height), gravity);
279+
280+
public void Extent(uint width, uint height, Gravity gravity, IMagickColor<QuantumType> backgroundColor)
281+
=> Extent(new MagickGeometry(width, height), gravity, backgroundColor);
282+
283+
public void Extent(IMagickGeometry geometry)
284+
=> Extent(geometry, Gravity.Undefined);
285+
286+
public void Extent(IMagickGeometry geometry, IMagickColor<QuantumType> backgroundColor)
287+
{
288+
Throw.IfNull(nameof(backgroundColor), backgroundColor);
289+
290+
NativeMagickImage.BackgroundColor_Set(backgroundColor);
291+
Extent(geometry);
292+
}
293+
294+
/// <summary>
295+
/// Extend the image as defined by the geometry.
296+
/// </summary>
297+
/// <param name="geometry">The geometry to extend the image to.</param>
298+
/// <param name="gravity">The placement gravity.</param>
299+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
300+
public void Extent(IMagickGeometry geometry, Gravity gravity)
301+
{
302+
Throw.IfNull(nameof(geometry), geometry);
303+
304+
SetResult(NativeMagickImage.Extent(geometry.ToString(), gravity));
305+
}
306+
307+
/// <summary>
308+
/// Extend the image as defined by the geometry.
309+
/// </summary>
310+
/// <param name="geometry">The geometry to extend the image to.</param>
311+
/// <param name="gravity">The placement gravity.</param>
312+
/// <param name="backgroundColor">The background color to use.</param>
313+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
314+
public void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<QuantumType> backgroundColor)
315+
{
316+
Throw.IfNull(nameof(backgroundColor), backgroundColor);
317+
318+
NativeMagickImage.BackgroundColor_Set(backgroundColor);
319+
Extent(geometry, gravity);
320+
}
321+
268322
public void Resize(uint width, uint height)
269323
=> Resize(new MagickGeometry(width, height));
270324

src/Magick.NET/MagickImage.cs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,7 +2774,10 @@ public void Evaluate(Channels channels, IMagickGeometry geometry, EvaluateOperat
27742774
/// <param name="height">The height to extend the image to.</param>
27752775
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
27762776
public void Extent(uint width, uint height)
2777-
=> Extent(new MagickGeometry(width, height));
2777+
{
2778+
using var mutator = new Mutator(_nativeInstance);
2779+
mutator.Extent(width, height);
2780+
}
27782781

27792782
/// <summary>
27802783
/// Extend the image as defined by the width and height.
@@ -2785,7 +2788,10 @@ public void Extent(uint width, uint height)
27852788
/// <param name="height">The height to extend the image to.</param>
27862789
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
27872790
public void Extent(int x, int y, uint width, uint height)
2788-
=> Extent(new MagickGeometry(x, y, width, height));
2791+
{
2792+
using var mutator = new Mutator(_nativeInstance);
2793+
mutator.Extent(x, y, width, height);
2794+
}
27892795

27902796
/// <summary>
27912797
/// Extend the image as defined by the width and height.
@@ -2795,7 +2801,10 @@ public void Extent(int x, int y, uint width, uint height)
27952801
/// <param name="backgroundColor">The background color to use.</param>
27962802
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
27972803
public void Extent(uint width, uint height, IMagickColor<QuantumType> backgroundColor)
2798-
=> Extent(new MagickGeometry(width, height), backgroundColor);
2804+
{
2805+
using var mutator = new Mutator(_nativeInstance);
2806+
mutator.Extent(width, height, backgroundColor);
2807+
}
27992808

28002809
/// <summary>
28012810
/// Extend the image as defined by the width and height.
@@ -2805,7 +2814,10 @@ public void Extent(uint width, uint height, IMagickColor<QuantumType> background
28052814
/// <param name="gravity">The placement gravity.</param>
28062815
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
28072816
public void Extent(uint width, uint height, Gravity gravity)
2808-
=> Extent(new MagickGeometry(width, height), gravity);
2817+
{
2818+
using var mutator = new Mutator(_nativeInstance);
2819+
mutator.Extent(width, height, gravity);
2820+
}
28092821

28102822
/// <summary>
28112823
/// Extend the image as defined by the width and height.
@@ -2816,15 +2828,21 @@ public void Extent(uint width, uint height, Gravity gravity)
28162828
/// <param name="backgroundColor">The background color to use.</param>
28172829
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
28182830
public void Extent(uint width, uint height, Gravity gravity, IMagickColor<QuantumType> backgroundColor)
2819-
=> Extent(new MagickGeometry(width, height), gravity, backgroundColor);
2831+
{
2832+
using var mutator = new Mutator(_nativeInstance);
2833+
mutator.Extent(width, height, gravity, backgroundColor);
2834+
}
28202835

28212836
/// <summary>
28222837
/// Extend the image as defined by the rectangle.
28232838
/// </summary>
28242839
/// <param name="geometry">The geometry to extend the image to.</param>
28252840
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
28262841
public void Extent(IMagickGeometry geometry)
2827-
=> Extent(geometry, Gravity.Undefined);
2842+
{
2843+
using var mutator = new Mutator(_nativeInstance);
2844+
mutator.Extent(geometry);
2845+
}
28282846

28292847
/// <summary>
28302848
/// Extend the image as defined by the geometry.
@@ -2834,10 +2852,8 @@ public void Extent(IMagickGeometry geometry)
28342852
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
28352853
public void Extent(IMagickGeometry geometry, IMagickColor<QuantumType> backgroundColor)
28362854
{
2837-
Throw.IfNull(nameof(backgroundColor), backgroundColor);
2838-
2839-
BackgroundColor = backgroundColor;
2840-
Extent(geometry);
2855+
using var mutator = new Mutator(_nativeInstance);
2856+
mutator.Extent(geometry, backgroundColor);
28412857
}
28422858

28432859
/// <summary>
@@ -2848,9 +2864,8 @@ public void Extent(IMagickGeometry geometry, IMagickColor<QuantumType> backgroun
28482864
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
28492865
public void Extent(IMagickGeometry geometry, Gravity gravity)
28502866
{
2851-
Throw.IfNull(nameof(geometry), geometry);
2852-
2853-
_nativeInstance.Extent(geometry.ToString(), gravity);
2867+
using var mutator = new Mutator(_nativeInstance);
2868+
mutator.Extent(geometry, gravity);
28542869
}
28552870

28562871
/// <summary>
@@ -2862,10 +2877,8 @@ public void Extent(IMagickGeometry geometry, Gravity gravity)
28622877
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
28632878
public void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<QuantumType> backgroundColor)
28642879
{
2865-
Throw.IfNull(nameof(backgroundColor), backgroundColor);
2866-
2867-
BackgroundColor = backgroundColor;
2868-
Extent(geometry, gravity);
2880+
using var mutator = new Mutator(_nativeInstance);
2881+
mutator.Extent(geometry, gravity, backgroundColor);
28692882
}
28702883

28712884
/// <summary>

src/Magick.NET/Native/MagickImage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
407407
public partial void EvaluateOperator(Channels channels, EvaluateOperator evaluateOperator, double value);
408408

409409
[Throws]
410-
[SetInstance]
411-
public partial void Extent(string geometry, Gravity gravity);
410+
public partial IntPtr Extent(string geometry, Gravity gravity);
412411

413412
[Throws]
414413
[SetInstance]

0 commit comments

Comments
 (0)