diff --git a/tests/ImageProcessorCore.Tests/Processors/Formats/EncoderDecoderTests.cs b/tests/ImageProcessorCore.Tests/Processors/Formats/EncoderDecoderTests.cs index 0899955f4..310fa4a3b 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Formats/EncoderDecoderTests.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Formats/EncoderDecoderTests.cs @@ -6,7 +6,7 @@ using Formats; using Xunit; - + using System.Linq; public class EncoderDecoderTests : ProcessorTestBase { [Fact] @@ -101,5 +101,39 @@ } } } + + [Fact] + public void ImageShouldPreservePixelByteOrderWhenSerialized() + { + if (!Directory.Exists("TestOutput/Serialized")) + { + Directory.CreateDirectory("TestOutput/Serialized"); + } + + foreach (string file in Files) + { + using (FileStream stream = File.OpenRead(file)) + { + Image image = new Image(stream); + byte[] serialized; + using (MemoryStream memoryStream = new MemoryStream()) + { + image.Save(memoryStream); + memoryStream.Flush(); + serialized = memoryStream.ToArray(); + } + + using (MemoryStream memoryStream = new MemoryStream(serialized)) + { + Image image2 = new Image(memoryStream); + + using (FileStream output = File.OpenWrite($"TestOutput/Serialized/{Path.GetFileName(file)}")) + { + image2.Save(output); + } + } + } + } + } } } \ No newline at end of file