How to manually implement zoom effect

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);
        }

VisioForge © 2006-2020

  • GitHub-Mark-64px
  • Twitter Социальные Иконка
  • VisioForge Facebook page
  • YouTube channel