How to manually implement zoom effect using OnVideoFrameBuffer event

Add VisioForge.Shared assembly reference to your application.

Implement 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);
        }
Please contact support to get help with this tutorial. Visit our GitHub page to get more code samples.
VisioForge © 2006 - 2021