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); }
public unsafe int FillBuffer(ref IMediaSampleImpl _sample) { IntPtr _ptr; _sample.GetPointer(out _ptr); int length = _sample.GetSize(); ShowNextImage(_ptr, length); //if (_settings.ShowDesktop) //{ // 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); }
public int FillBuffer(ref IMediaSampleImpl _sample) { #if HAMED_LOG_METHOD_INFO MethodBase method = new StackTrace().GetFrame(0).GetMethod(); Console.WriteLine(this.GetType().FullName + " - " + method.Name + " - " + method.ToString()); #endif if (m_hBitmap == IntPtr.Zero) { m_hBitmap = CreateCompatibleBitmap(m_hScreenDC, m_nWidth, Math.Abs(m_nHeight)); } IntPtr _ptr; _sample.GetPointer(out _ptr); 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); }
/// <summary> /// Fills the buffer. /// </summary> /// <param name="pSample">The p sample.</param> /// <returns></returns> public override int FillBuffer(ref IMediaSampleImpl pSample) { Resource screenResource; OutputDuplicateFrameInformation duplicateFrameInformation; m_DuplicatedOutput.AcquireNextFrame(10000, out duplicateFrameInformation, out screenResource); ResourceRegion region = new ResourceRegion( Math.Max(m_CaptureSettings.m_Rect.left, 0), Math.Max(m_CaptureSettings.m_Rect.top, 0), 0, Math.Min(m_CaptureSettings.m_Rect.right, m_Output.Description.DesktopBounds.Right), Math.Min(m_CaptureSettings.m_Rect.bottom, m_Output.Description.DesktopBounds.Bottom), 1 ); m_Device.ImmediateContext.CopySubresourceRegion( screenResource.QueryInterface <SharpDX.Direct3D11.Resource>(), 0, region, m_ScreenTexture.QueryInterface <SharpDX.Direct3D11.Resource>(), 0 ); DataBox mapSource = m_Device.ImmediateContext.MapSubresource(m_ScreenTexture, 0, MapMode.Read, MapFlags.None); IntPtr pImageDest; pSample.GetPointer(out pImageDest); var sourcePtr = mapSource.DataPointer; var destPtr = IntPtr.Add(pImageDest, (m_nHeight - 1) * m_nWidth * 4); for (int y = 0; y < m_nHeight; y++) { Utilities.CopyMemory(destPtr, sourcePtr, m_nWidth * 4); sourcePtr = IntPtr.Add(sourcePtr, mapSource.RowPitch); destPtr = IntPtr.Subtract(destPtr, m_nWidth * 4); } pSample.SetActualDataLength(CurrentMediaType.sampleSize); pSample.SetSyncPoint(true); long _stop = m_lLastSampleTime + m_nAvgTimePerFrame; pSample.SetTime(m_lLastSampleTime, _stop); m_lLastSampleTime = _stop; m_Device.ImmediateContext.UnmapSubresource(m_ScreenTexture, 0); screenResource.Dispose(); m_DuplicatedOutput.ReleaseFrame(); return(NOERROR); }
public int FillBuffer(ref IMediaSampleImpl _sample) { IntPtr _ptr; _sample.GetPointer(out _ptr); CapturePipeline.Instance.updateData(_ptr); _sample.SetActualDataLength(_sample.GetSize()); _sample.SetSyncPoint(true); return(NOERROR); }