Skip to content

Commit 9e328e4

Browse files
committed
fix export gif and add tests
1 parent ff49954 commit 9e328e4

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

IronSoftware.Drawing/IronSoftware.Drawing.Common.Tests/UnitTests/AnyBitmapFunctionality.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,5 +1083,30 @@ public void DW_34_ShouldNotThrowOutOfMemory(string filename)
10831083

10841084
images.ForEach(bitmap => bitmap.Dispose());
10851085
}
1086+
1087+
[FactWithAutomaticDisplayName]
1088+
public void AnyBitmap_ExportGif_Should_Works()
1089+
{
1090+
string imagePath = GetRelativeFilePath("van-gogh-starry-night-vincent-van-gogh.jpg");
1091+
var anyBitmap = AnyBitmap.FromFile(imagePath);
1092+
1093+
using var resultExport = new MemoryStream();
1094+
anyBitmap.ExportStream(resultExport, AnyBitmap.ImageFormat.Gif);
1095+
resultExport.Length.Should().NotBe(0);
1096+
Image.DetectFormat(resultExport.ToArray()).Should().Be(SixLabors.ImageSharp.Formats.Gif.GifFormat.Instance);
1097+
}
1098+
1099+
[FactWithAutomaticDisplayName]
1100+
public void AnyBitmap_ExportTiff_Should_Works()
1101+
{
1102+
string imagePath = GetRelativeFilePath("van-gogh-starry-night-vincent-van-gogh.jpg");
1103+
var anyBitmap = AnyBitmap.FromFile(imagePath);
1104+
1105+
using var resultExport = new MemoryStream();
1106+
anyBitmap.ExportStream(resultExport, AnyBitmap.ImageFormat.Tiff);
1107+
resultExport.Length.Should().NotBe(0);
1108+
Image.DetectFormat(resultExport.ToArray()).Should().Be(SixLabors.ImageSharp.Formats.Tiff.TiffFormat.Instance);
1109+
}
1110+
10861111
}
10871112
}

IronSoftware.Drawing/IronSoftware.Drawing.Common/AnyBitmap.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,11 +3321,10 @@ private static void InternalSaveAsMultiPageGif(IEnumerable<Image> images, Stream
33213321
// Add the correctly-sized new frame to the master GIF's frame collection.
33223322
gif.Frames.AddFrame(resizedFrame.Frames.RootFrame);
33233323
}
3324-
3325-
// Save the final result to the provided stream.
3326-
gif.SaveAsGif(stream);
3327-
stream.Position = 0;
3328-
}
3324+
}
3325+
// Save the final result to the provided stream.
3326+
gif.SaveAsGif(stream);
3327+
stream.Position = 0;
33293328
}
33303329

33313330
#endregion

0 commit comments

Comments
 (0)