Skip to content

Commit

Permalink
Moved Extent to IMagickImageCreateOperations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Nov 17, 2024
1 parent 2350b3a commit 8f5e970
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 97 deletions.
42 changes: 0 additions & 42 deletions src/Magick.NET.Core/IMagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -965,48 +965,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Evaluate(Channels channels, IMagickGeometry geometry, EvaluateOperator evaluateOperator, Percentage percentage);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="x">The X offset from origin.</param>
/// <param name="y">The Y offset from origin.</param>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(int x, int y, uint width, uint height);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height, Gravity gravity);

/// <summary>
/// Extend the image as defined by the rectangle.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry);

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry, Gravity gravity);

/// <summary>
/// Flip image (reflect each scanline in the vertical direction).
/// </summary>
Expand Down
36 changes: 36 additions & 0 deletions src/Magick.NET.Core/IMagickImageCloneMutator{TQuantumType}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,40 @@ public interface IMagickImageCloneMutator<TQuantumType> : IMagickImageCreateOper
/// <param name="alphaBlue">The alpha percentage for blue.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Colorize(IMagickColor<TQuantumType> color, Percentage alphaRed, Percentage alphaGreen, Percentage alphaBlue);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height, IMagickColor<TQuantumType> backgroundColor);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry, IMagickColor<TQuantumType> backgroundColor);

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);
}
42 changes: 42 additions & 0 deletions src/Magick.NET.Core/IMagickImageCreateOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,48 @@ public interface IMagickImageCreateOperations
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Enhance();

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="x">The X offset from origin.</param>
/// <param name="y">The Y offset from origin.</param>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(int x, int y, uint width, uint height);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height, Gravity gravity);

/// <summary>
/// Extend the image as defined by the rectangle.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry);

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry, Gravity gravity);

/// <summary>
/// Resize image to specified size.
/// <para />
Expand Down
36 changes: 0 additions & 36 deletions src/Magick.NET.Core/IMagickImage{TQuantumType}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,42 +201,6 @@ public partial interface IMagickImage<TQuantumType> : IMagickImage, IComparable<
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Draw(IDrawables<TQuantumType> drawables);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height, IMagickColor<TQuantumType> backgroundColor);

/// <summary>
/// Extend the image as defined by the width and height.
/// </summary>
/// <param name="width">The width to extend the image to.</param>
/// <param name="height">The height to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(uint width, uint height, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry, IMagickColor<TQuantumType> backgroundColor);

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<TQuantumType> backgroundColor);

/// <summary>
/// Floodfill pixels matching color (within fuzz factor) of target pixel(x,y) with replacement
/// alpha value using method.
Expand Down
54 changes: 54 additions & 0 deletions src/Magick.NET/MagickImage.CloneMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,60 @@ public void Encipher(string passphrase)
public void Enhance()
=> SetResult(NativeMagickImage.Enhance());

public void Extent(uint width, uint height)
=> Extent(new MagickGeometry(width, height));

public void Extent(int x, int y, uint width, uint height)
=> Extent(new MagickGeometry(x, y, width, height));

public void Extent(uint width, uint height, IMagickColor<QuantumType> backgroundColor)
=> Extent(new MagickGeometry(width, height), backgroundColor);

public void Extent(uint width, uint height, Gravity gravity)
=> Extent(new MagickGeometry(width, height), gravity);

public void Extent(uint width, uint height, Gravity gravity, IMagickColor<QuantumType> backgroundColor)
=> Extent(new MagickGeometry(width, height), gravity, backgroundColor);

public void Extent(IMagickGeometry geometry)
=> Extent(geometry, Gravity.Undefined);

public void Extent(IMagickGeometry geometry, IMagickColor<QuantumType> backgroundColor)
{
Throw.IfNull(nameof(backgroundColor), backgroundColor);

NativeMagickImage.BackgroundColor_Set(backgroundColor);
Extent(geometry);
}

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Extent(IMagickGeometry geometry, Gravity gravity)
{
Throw.IfNull(nameof(geometry), geometry);

SetResult(NativeMagickImage.Extent(geometry.ToString(), gravity));
}

/// <summary>
/// Extend the image as defined by the geometry.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <param name="gravity">The placement gravity.</param>
/// <param name="backgroundColor">The background color to use.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<QuantumType> backgroundColor)
{
Throw.IfNull(nameof(backgroundColor), backgroundColor);

NativeMagickImage.BackgroundColor_Set(backgroundColor);
Extent(geometry, gravity);
}

public void Resize(uint width, uint height)
=> Resize(new MagickGeometry(width, height));

Expand Down
47 changes: 30 additions & 17 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,10 @@ public void Evaluate(Channels channels, IMagickGeometry geometry, EvaluateOperat
/// <param name="height">The height to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Extent(uint width, uint height)
=> Extent(new MagickGeometry(width, height));
{
using var mutator = new Mutator(_nativeInstance);
mutator.Extent(width, height);
}

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

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

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

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

/// <summary>
/// Extend the image as defined by the rectangle.
/// </summary>
/// <param name="geometry">The geometry to extend the image to.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Extent(IMagickGeometry geometry)
=> Extent(geometry, Gravity.Undefined);
{
using var mutator = new Mutator(_nativeInstance);
mutator.Extent(geometry);
}

/// <summary>
/// Extend the image as defined by the geometry.
Expand All @@ -2834,10 +2852,8 @@ public void Extent(IMagickGeometry geometry)
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Extent(IMagickGeometry geometry, IMagickColor<QuantumType> backgroundColor)
{
Throw.IfNull(nameof(backgroundColor), backgroundColor);

BackgroundColor = backgroundColor;
Extent(geometry);
using var mutator = new Mutator(_nativeInstance);
mutator.Extent(geometry, backgroundColor);
}

/// <summary>
Expand All @@ -2848,9 +2864,8 @@ public void Extent(IMagickGeometry geometry, IMagickColor<QuantumType> backgroun
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Extent(IMagickGeometry geometry, Gravity gravity)
{
Throw.IfNull(nameof(geometry), geometry);

_nativeInstance.Extent(geometry.ToString(), gravity);
using var mutator = new Mutator(_nativeInstance);
mutator.Extent(geometry, gravity);
}

/// <summary>
Expand All @@ -2862,10 +2877,8 @@ public void Extent(IMagickGeometry geometry, Gravity gravity)
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Extent(IMagickGeometry geometry, Gravity gravity, IMagickColor<QuantumType> backgroundColor)
{
Throw.IfNull(nameof(backgroundColor), backgroundColor);

BackgroundColor = backgroundColor;
Extent(geometry, gravity);
using var mutator = new Mutator(_nativeInstance);
mutator.Extent(geometry, gravity, backgroundColor);
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions src/Magick.NET/Native/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
public partial void EvaluateOperator(Channels channels, EvaluateOperator evaluateOperator, double value);

[Throws]
[SetInstance]
public partial void Extent(string geometry, Gravity gravity);
public partial IntPtr Extent(string geometry, Gravity gravity);

[Throws]
[SetInstance]
Expand Down

0 comments on commit 8f5e970

Please sign in to comment.