Skip to content

Commit bf3c86f

Browse files
committed
Make it possible to use the TemporaryDefines with a INativeMagickImage.
1 parent a2374fc commit bf3c86f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/Magick.NET/Helpers/TemporaryDefines.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ namespace ImageMagick;
99

1010
internal sealed class TemporaryDefines : IDisposable
1111
{
12-
private readonly IMagickImage _image;
12+
private readonly INativeMagickImage _image;
1313
private readonly List<string> _names = new();
1414

1515
public TemporaryDefines(IMagickImage image)
16+
{
17+
_image = MagickImage.GetNativeImage(image);
18+
}
19+
20+
public TemporaryDefines(INativeMagickImage image)
1621
{
1722
_image = image;
1823
}
@@ -34,10 +39,10 @@ public void SetArtifact(string name, string? value)
3439
_image.SetArtifact(name, value);
3540
}
3641

37-
public void SetArtifact(string name, bool value)
42+
public void SetArtifact(string name, bool flag)
3843
{
3944
_names.Add(name);
40-
_image.SetArtifact(name, value);
45+
_image.SetArtifact(name, flag ? "true" : "false");
4146
}
4247

4348
public void SetArtifact<TValue>(string name, TValue? value)

src/Magick.NET/Native/INativeMagickImage.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@ namespace ImageMagick
88
internal interface INativeMagickImage
99
{
1010
IntPtr Fx(string expression, Channels channels);
11+
12+
void RemoveArtifact(string name);
13+
14+
void SetArtifact(string name, string value);
1115
}
1216
}

0 commit comments

Comments
 (0)