Skip to content

Commit 619b9d9

Browse files
committed
Added IMagickImageCloneMutator<QuantumType>.
1 parent 8f25f14 commit 619b9d9

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
22
// Licensed under the Apache License, Version 2.0.
33

4+
using System;
5+
46
namespace ImageMagick;
57

68
/// <summary>
79
/// Interface that can be used to efficiently clone and mutate an image.
810
/// </summary>
9-
public interface IMagickImageCloneMutator : IMagickImageCreateOperations
11+
/// <typeparam name="TQuantumType">The quantum type.</typeparam>
12+
public interface IMagickImageCloneMutator<TQuantumType> : IMagickImageCreateOperations<TQuantumType>
13+
where TQuantumType : struct, IConvertible
1014
{
1115
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System;
5+
6+
namespace ImageMagick;
7+
8+
/// <summary>
9+
/// Interface that represents ImageMagick operations that create a new image.
10+
/// </summary>
11+
/// <typeparam name="TQuantumType">The quantum type.</typeparam>
12+
public interface IMagickImageCreateOperations<TQuantumType> : IMagickImageCreateOperations
13+
where TQuantumType : struct, IConvertible
14+
{
15+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public partial interface IMagickImage<TQuantumType> : IMagickImage, IComparable<
5050
/// </summary>
5151
/// <param name="action">The mutate action to execute on the clone.</param>
5252
/// <returns>A clone of the current image.</returns>
53-
IMagickImage<TQuantumType> CloneAndMutate(Action<IMagickImageCloneMutator> action);
53+
IMagickImage<TQuantumType> CloneAndMutate(Action<IMagickImageCloneMutator<TQuantumType>> action);
5454

5555
/// <summary>
5656
/// Creates a clone of the current image with the specified geometry.

src/Magick.NET/MagickImage.CloneMutator.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@
44
using System;
55
using ImageMagick.Drawing;
66

7+
#if Q8
8+
using QuantumType = System.Byte;
9+
#elif Q16
10+
using QuantumType = System.UInt16;
11+
#elif Q16HDRI
12+
using QuantumType = System.Single;
13+
#else
14+
#error Not implemented!
15+
#endif
16+
717
namespace ImageMagick;
818

919
/// <content />
1020
public partial class MagickImage
1121
{
12-
private class CloneMutator : IMagickImageCloneMutator, IDisposable
22+
private class CloneMutator : IMagickImageCloneMutator<QuantumType>, IDisposable
1323
{
1424
private IntPtr _result = IntPtr.Zero;
1525

src/Magick.NET/MagickImage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ public IMagickImage<QuantumType> Clone()
16231623
/// </summary>
16241624
/// <param name="action">The mutate action to execute on the clone.</param>
16251625
/// <returns>A clone of the current image.</returns>
1626-
public IMagickImage<QuantumType> CloneAndMutate(Action<IMagickImageCloneMutator> action)
1626+
public IMagickImage<QuantumType> CloneAndMutate(Action<IMagickImageCloneMutator<QuantumType>> action)
16271627
{
16281628
using var imageCreator = new CloneMutator(_nativeInstance);
16291629
action(imageCreator);

0 commit comments

Comments
 (0)