|
|
|
@ -40,25 +40,27 @@ namespace ImageSharp.Tests.Formats.Png |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithTestPatternImages(100, 100, PixelTypes.Rgba32)] |
|
|
|
public void CanSaveIndexedPng<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
// does saving a file then repoening mean both files are identical???
|
|
|
|
using (Image<TPixel> image = provider.GetImage()) |
|
|
|
using (MemoryStream ms = new MemoryStream()) |
|
|
|
{ |
|
|
|
// image.Save(provider.Utility.GetTestOutputFileName("bmp"));
|
|
|
|
image.Save(ms, new PngEncoder() { PaletteSize = 256 }); |
|
|
|
ms.Position = 0; |
|
|
|
using (Image<Rgba32> img2 = Image.Load<Rgba32>(ms, new PngDecoder())) |
|
|
|
{ |
|
|
|
// img2.Save(provider.Utility.GetTestOutputFileName("bmp", "_loaded"), new BmpEncoder());
|
|
|
|
ImageComparer.CheckSimilarity(image, img2, 0.03f); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// JJS: Disabled for now as the decoder now correctly decodes the full pixel components if the
|
|
|
|
// paletted image has alpha of 0
|
|
|
|
//[Theory]
|
|
|
|
//[WithTestPatternImages(100, 100, PixelTypes.Rgba32)]
|
|
|
|
//public void CanSaveIndexedPng<TPixel>(TestImageProvider<TPixel> provider)
|
|
|
|
// where TPixel : struct, IPixel<TPixel>
|
|
|
|
//{
|
|
|
|
// // does saving a file then repoening mean both files are identical???
|
|
|
|
// using (Image<TPixel> image = provider.GetImage())
|
|
|
|
// using (MemoryStream ms = new MemoryStream())
|
|
|
|
// {
|
|
|
|
// // image.Save(provider.Utility.GetTestOutputFileName("bmp"));
|
|
|
|
// image.Save(ms, new PngEncoder() { PaletteSize = 256 });
|
|
|
|
// ms.Position = 0;
|
|
|
|
// using (Image<Rgba32> img2 = Image.Load<Rgba32>(ms, new PngDecoder()))
|
|
|
|
// {
|
|
|
|
// // img2.Save(provider.Utility.GetTestOutputFileName("bmp", "_loaded"), new BmpEncoder());
|
|
|
|
// ImageComparer.CheckSimilarity(image, img2, 0.03f);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
// JJS: Commented out for now since the test does not take into lossy nature of indexing.
|
|
|
|
//[Theory]
|
|
|
|
|