Skip to content

Commit

Permalink
Use TemporaryDefines for the defines instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Aug 5, 2024
1 parent 730089e commit b75c257
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Magick.NET/Helpers/TemporaryDefines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace ImageMagick;

internal sealed class TemporaryDefines : IDisposable
{
private readonly MagickImage _image;
private readonly IMagickImage _image;
private readonly List<string> _names = new();

public TemporaryDefines(MagickImage image)
public TemporaryDefines(IMagickImage image)
{
_image = image;
}
Expand Down
11 changes: 3 additions & 8 deletions src/Magick.NET/MagickImageCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,19 +442,14 @@ public void Complex(IComplexSettings complexSettings)
{
Throw.IfNull(nameof(complexSettings), complexSettings);

using var imageAttacher = new TemporaryImageAttacher(_images);
using var temporaryDefines = new TemporaryDefines(_images[0]);

if (complexSettings.SignalToNoiseRatio is not null)
_images[0].SetArtifact("complex:snr", complexSettings.SignalToNoiseRatio.Value.ToString(CultureInfo.InvariantCulture));
temporaryDefines.SetArtifact("complex:snr", complexSettings.SignalToNoiseRatio.Value.ToString(CultureInfo.InvariantCulture));

using var imageAttacher = new TemporaryImageAttacher(_images);
var images = _nativeInstance.Complex(_images[0], complexSettings.ComplexOperator);
ReplaceImages(images);

if (complexSettings.SignalToNoiseRatio is not null)
{
foreach (var image in _images)
image.RemoveArtifact("complex:snr");
}
}

/// <summary>
Expand Down

0 comments on commit b75c257

Please sign in to comment.