コード例 #1
0
 private static void ImportFrameAs <TPixel>(ImageFrameCollection source, ImageFrameCollection destination, int index)
     where TPixel : struct, IPixel <TPixel>
 {
     using (Image temp = source.CloneFrame(index))
     {
         using (Image <TPixel> temp2 = temp.CloneAs <TPixel>())
         {
             destination.AddFrame(temp2.Frames.RootFrame);
         }
     }
 }
コード例 #2
0
            public void CloneFrame <TPixel>(TestImageProvider <TPixel> provider)
                where TPixel : struct, IPixel <TPixel>
            {
                using (Image <TPixel> img = provider.GetImage())
                {
                    ImageFrameCollection nonGenericFrameCollection = img.Frames;

                    nonGenericFrameCollection.AddFrame(new ImageFrame <TPixel>(Configuration.Default, 10, 10)); // add a frame anyway
                    using (Image cloned = nonGenericFrameCollection.CloneFrame(0))
                    {
                        Assert.Equal(2, img.Frames.Count);

                        var expectedClone = (Image <TPixel>)cloned;

                        expectedClone.ComparePixelBufferTo(img.GetPixelSpan());
                    }
                }
            }
コード例 #3
0
            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);
                    }
                }
            }
コード例 #4
0
            public void CloneFrame <TPixel>(TestImageProvider <TPixel> provider)
                where TPixel : unmanaged, IPixel <TPixel>
            {
                using (Image <TPixel> img = provider.GetImage())
                {
                    ImageFrameCollection nonGenericFrameCollection = img.Frames;

                    nonGenericFrameCollection.AddFrame(new ImageFrame <TPixel>(Configuration.Default, 10, 10)); // add a frame anyway
                    using (Image cloned = nonGenericFrameCollection.CloneFrame(0))
                    {
                        Assert.Equal(2, img.Frames.Count);

                        var expectedClone = (Image <TPixel>)cloned;

                        Assert.True(img.DangerousTryGetSinglePixelMemory(out Memory <TPixel> imgMem));
                        expectedClone.ComparePixelBufferTo(imgMem);
                    }
                }
            }
コード例 #5
0
            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());
                    }
                }
            }