Browse Source

Fix PngMetadata copy

pull/2713/head
SpaceCheetah 2 years ago
parent
commit
85fd4311f1
No known key found for this signature in database GPG Key ID: A60F20D29141DFF9
  1. 3
      src/ImageSharp/Formats/Png/PngMetadata.cs
  2. 4
      tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs

3
src/ImageSharp/Formats/Png/PngMetadata.cs

@ -29,6 +29,7 @@ public class PngMetadata : IDeepCloneable
this.InterlaceMethod = other.InterlaceMethod; this.InterlaceMethod = other.InterlaceMethod;
this.TransparentColor = other.TransparentColor; this.TransparentColor = other.TransparentColor;
this.RepeatCount = other.RepeatCount; this.RepeatCount = other.RepeatCount;
this.DefaultImageAnimated = other.DefaultImageAnimated;
if (other.ColorTable?.Length > 0) if (other.ColorTable?.Length > 0)
{ {
@ -86,7 +87,7 @@ public class PngMetadata : IDeepCloneable
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the default image is shown as part of the animated sequence /// Gets or sets a value indicating whether the default image is shown as part of the animated sequence
/// </summary> /// </summary>
public bool DefaultImageAnimated { get; set; } public bool DefaultImageAnimated { get; set; } = true;
/// <inheritdoc/> /// <inheritdoc/>
public IDeepCloneable DeepClone() => new PngMetadata(this); public IDeepCloneable DeepClone() => new PngMetadata(this);

4
tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs

@ -32,7 +32,8 @@ public class PngMetadataTests
InterlaceMethod = PngInterlaceMode.Adam7, InterlaceMethod = PngInterlaceMode.Adam7,
Gamma = 2, Gamma = 2,
TextData = new List<PngTextData> { new PngTextData("name", "value", "foo", "bar") }, TextData = new List<PngTextData> { new PngTextData("name", "value", "foo", "bar") },
RepeatCount = 123 RepeatCount = 123,
DefaultImageAnimated = false
}; };
PngMetadata clone = (PngMetadata)meta.DeepClone(); PngMetadata clone = (PngMetadata)meta.DeepClone();
@ -44,6 +45,7 @@ public class PngMetadataTests
Assert.False(meta.TextData.Equals(clone.TextData)); Assert.False(meta.TextData.Equals(clone.TextData));
Assert.True(meta.TextData.SequenceEqual(clone.TextData)); Assert.True(meta.TextData.SequenceEqual(clone.TextData));
Assert.True(meta.RepeatCount == clone.RepeatCount); Assert.True(meta.RepeatCount == clone.RepeatCount);
Assert.True(meta.DefaultImageAnimated == clone.DefaultImageAnimated);
clone.BitDepth = PngBitDepth.Bit2; clone.BitDepth = PngBitDepth.Bit2;
clone.ColorType = PngColorType.Palette; clone.ColorType = PngColorType.Palette;

Loading…
Cancel
Save