namespace ImageSharp.Tests { using ImageSharp.PixelFormats; using ImageSharp.Tests.TestUtilities.ReferenceCodecs; using Xunit; using Xunit.Abstractions; public class ReferenceCodecTests { private ITestOutputHelper Output { get; } public ReferenceCodecTests(ITestOutputHelper output) { this.Output = output; } [Theory] [WithTestPatternImages(20, 20, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void ToSystemDrawingBitmap(TestImageProvider provider) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) { using (System.Drawing.Bitmap sdBitmap = SystemDrawingBridge.ToSystemDrawingBitmap(image)) { string fileName = provider.Utility.GetTestOutputFileName("png"); sdBitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png); } } } [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void FromSystemDrawingBitmap(TestImageProvider dummyProvider) where TPixel : struct, IPixel { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); using (var sdBitmap = new System.Drawing.Bitmap(path)) { using (Image image = SystemDrawingBridge.FromSystemDrawingBitmap(sdBitmap)) { image.DebugSave(dummyProvider); } } } [Theory] [WithBlankImages(1, 1, PixelTypes.Rgba32 | PixelTypes.Bgra32)] public void OpenWithReferenceDecoder(TestImageProvider dummyProvider) where TPixel : struct, IPixel { string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash); using (Image image = Image.Load(path, ReferenceDecoder.Instance)) { image.DebugSave(dummyProvider); } } [Theory] [WithTestPatternImages(20, 20, PixelTypes.Rgba32 | PixelTypes.Argb32)] public void SaveWithReferenceEncoder(TestImageProvider provider) where TPixel : struct, IPixel { using (Image image = provider.GetImage()) { provider.Utility.SaveTestOutputFile(image, "png", ReferenceEncoder.Png); } } } }