public void ExtractFrame <TPixel>(TestImageProvider <TPixel> provider) where TPixel : struct, IPixel <TPixel> { using (Image <TPixel> img = provider.GetImage()) { var sourcePixelData = img.GetPixelSpan().ToArray(); ImageFrameCollection nonGenericFrameCollection = img.Frames; nonGenericFrameCollection.AddFrame(new ImageFrame <TPixel>(Configuration.Default, 10, 10)); using (Image cloned = nonGenericFrameCollection.ExportFrame(0)) { Assert.Equal(1, img.Frames.Count); var expectedClone = (Image <TPixel>)cloned; expectedClone.ComparePixelBufferTo(sourcePixelData); } } }
public void ExtractFrame <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { using (Image <TPixel> img = provider.GetImage()) { Assert.True(img.DangerousTryGetSinglePixelMemory(out Memory <TPixel> imgMem)); TPixel[] sourcePixelData = imgMem.ToArray(); ImageFrameCollection nonGenericFrameCollection = img.Frames; nonGenericFrameCollection.AddFrame(new ImageFrame <TPixel>(Configuration.Default, 10, 10)); using (Image cloned = nonGenericFrameCollection.ExportFrame(0)) { Assert.Equal(1, img.Frames.Count); var expectedClone = (Image <TPixel>)cloned; expectedClone.ComparePixelBufferTo(sourcePixelData.AsSpan()); } } }