예제 #1
0
        public void Dispose_DisposesAllInnerFrames()
        {
            var collection = new ImageFrameCollection <Rgba32>(this.image, new[] {
                new ImageFrame <Rgba32>(Configuration.Default.MemoryManager, 10, 10),
                new ImageFrame <Rgba32>(Configuration.Default.MemoryManager, 10, 10),
            });

            IPixelSource <Rgba32>[] framesSnapShot = collection.OfType <IPixelSource <Rgba32> >().ToArray();
            collection.Dispose();

            Assert.All(framesSnapShot, f =>
            {
                // the pixel source of the frame is null after its been disposed.
                Assert.Null(f.PixelBuffer);
            });
        }
            public void Dispose_DisposesAllInnerFrames()
            {
                using var imageFrame1 = new ImageFrame <Rgba32>(Configuration.Default, 10, 10);
                using var imageFrame2 = new ImageFrame <Rgba32>(Configuration.Default, 10, 10);
                var collection = new ImageFrameCollection <Rgba32>(
                    this.Image,
                    new[] { imageFrame1, imageFrame2 });

                IPixelSource <Rgba32>[] framesSnapShot = collection.OfType <IPixelSource <Rgba32> >().ToArray();
                collection.Dispose();

                Assert.All(
                    framesSnapShot,
                    f =>
                {
                    // The pixel source of the frame is null after its been disposed.
                    Assert.Null(f.PixelBuffer);
                });
            }