Пример #1
0
        public unsafe int FillBuffer(ref IMediaSampleImpl _sample)
        {
            IntPtr _ptr;

            _sample.GetPointer(out _ptr);
            int length = _sample.GetSize();

            if (!KinectCamSettigns.Default.Desktop)
            {
                KinectHelper.GenerateFrame(_ptr, length, KinectCamSettigns.Default.Mirrored, KinectCamSettigns.Default.Zoom);
            }
            else
            {
                if (m_hBitmap == IntPtr.Zero)
                {
                    m_hBitmap = CreateCompatibleBitmap(m_hScreenDC, m_nWidth, Math.Abs(m_nHeight));
                }
                IntPtr hOldBitmap = SelectObject(m_hMemDC, m_hBitmap);
                StretchBlt(m_hMemDC, 0, 0, m_nWidth, Math.Abs(m_nHeight), m_hScreenDC, 0, 0, m_nMaxWidth, m_nMaxHeight, TernaryRasterOperations.SRCCOPY);
                SelectObject(m_hMemDC, hOldBitmap);
                GetDIBits(m_hMemDC, m_hBitmap, 0, (uint)Math.Abs(m_nHeight), _ptr, ref m_bmi, 0);
            }

            _sample.SetActualDataLength(_sample.GetSize());
            _sample.SetSyncPoint(true);

            return(NOERROR);
        }
Пример #2
0
        public override int Stop()
        {
            KinectHelper.DisposeSensor();
            int hr = base.Stop();

            if (m_hBitmap != IntPtr.Zero)
            {
                DeleteObject(m_hBitmap);
                m_hBitmap = IntPtr.Zero;
            }
            if (m_hScreenDC != IntPtr.Zero)
            {
                DeleteDC(m_hScreenDC);
                m_hScreenDC = IntPtr.Zero;
            }
            if (m_hMemDC != IntPtr.Zero)
            {
                DeleteDC(m_hMemDC);
                m_hMemDC = IntPtr.Zero;
            }
            return(hr);
        }