Skip to main content

How to manually implement the zoom effect using the OnVideoFrameBuffer event?

Products: Video Capture SDK .Net, Video Edit SDK .Net, Media Player SDK .Net

Sample code

Implement the OnVideoFrameBuffer event.

Sample code for Media Player SDK .Net Main Demo.

        private IntPtr tempBuffer = IntPtr.Zero;

IntPtr tmpZoomFrameBuffer = IntPtr.Zero;

private int tmpZoomFrameBufferSize = 0;

private void MediaPlayer1_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e)
{
if (tempBuffer == IntPtr.Zero)
{
tempBuffer = Marshal.AllocCoTaskMem(e.Frame.DataSize);
}

const double zoom = 2.0;
FastImageProcessing.EffectZoom(
e.Frame.Data,
e.Frame.Width,
e.Frame.Height,
tempBuffer,
zoom,
zoom,
0,
0,
tmpZoomFrameBuffer,
ref tmpZoomFrameBufferSize);

if (tmpZoomFrameBufferSize > 0 && tmpZoomFrameBuffer == IntPtr.Zero)
{
tmpZoomFrameBuffer = Marshal.AllocCoTaskMem(tmpZoomFrameBufferSize);
return;
}

FastImageProcessing.CopyMemory(tempBuffer, e.Frame.Data, e.Frame.DataSize);
}

Required redists

  • SDK redist

Visit our GitHub page to get more code samples.