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

Sample code

Add VisioForge.Shared assembly reference to your application.

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;
            VisioForge.Shared.MFP.MFP.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;
            }

            VisioForge.Shared.MFP.MFP.CopyMemory(tempBuffer, e.Frame.Data, e.Frame.DataSize);
        }

Required redists

Please contact support to get help with this tutorial. Visit our GitHub page to get more code samples.
abstract 2abstract 1abstract 3
logo
VisioForge © 2006 - 2021