示例#1
0
        public FrameSet AllocateCompositeFrame(IList <Frame> frames)
        {
            if (frames == null)
            {
                throw new ArgumentNullException(nameof(frames));
            }

            IntPtr frame_refs = IntPtr.Zero;

            try {
                object error;
                int    fl = frames.Count;
                frame_refs = Marshal.AllocHGlobal(fl * IntPtr.Size);
                for (int i = 0; i < fl; i++)
                {
                    var fr = frames[i].m_instance.Handle;
                    Marshal.WriteIntPtr(frame_refs, i * IntPtr.Size, fr);
                    NativeMethods.rs2_frame_add_ref(fr, out error);
                }

                var frame_ref = NativeMethods.rs2_allocate_composite_frame(m_instance.Handle, frame_refs, fl, out error);
                return(FrameSet.Create(frame_ref));
            }
            finally
            {
                if (frame_refs != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(frame_refs);
                }
            }
        }
示例#2
0
        public FrameSet AllocateCompositeFrame(FramesReleaser releaser, params Frame[] frames)
        {
            object error;
            var    frame_refs = frames.Select(x => x.m_instance.Handle).ToArray();

            foreach (var fref in frame_refs)
            {
                NativeMethods.rs2_frame_add_ref(fref, out error);
            }
            var frame_ref = NativeMethods.rs2_allocate_composite_frame(m_instance.Handle, frame_refs, frames.Count(), out error);

            return(FramesReleaser.ScopedReturn(releaser, new FrameSet(frame_ref)));
        }