AForge.Video.DirectShow.VideoCaptureDevice.OnNewFrame C# (CSharp) Method

OnNewFrame() private method

Notifies clients about new frame.
private OnNewFrame ( Bitmap image ) : void
image Bitmap New frame's image.
return void
        private void OnNewFrame( Bitmap image )
        {
            framesReceived++;
            bytesReceived += image.Width * image.Height * ( Bitmap.GetPixelFormatSize( image.PixelFormat ) >> 3 );

            if ( ( !stopEvent.WaitOne( 0, false ) ) && ( NewFrame != null ) )
                NewFrame( this, new NewFrameEventArgs( image ) );
        }

Usage Example

Example #1
0
 public unsafe int BufferCB(double sampleTime, IntPtr buffer, int bufferLen)
 {
     if (parent.NewFrame != null)
     {
         Bitmap     bitmap     = new Bitmap(width, height, PixelFormat.Format24bppRgb);
         BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
         int        stride     = bitmapData.Stride;
         int        stride2    = bitmapData.Stride;
         byte *     ptr        = (byte *)bitmapData.Scan0.ToPointer() + (long)stride2 * (long)(height - 1);
         byte *     ptr2       = (byte *)buffer.ToPointer();
         for (int i = 0; i < height; i++)
         {
             Win32.memcpy(ptr, ptr2, stride);
             ptr  -= stride2;
             ptr2 += stride;
         }
         bitmap.UnlockBits(bitmapData);
         if (snapshotMode)
         {
             parent.OnSnapshotFrame(bitmap);
         }
         else
         {
             parent.OnNewFrame(bitmap);
         }
         bitmap.Dispose();
     }
     return(0);
 }
All Usage Examples Of AForge.Video.DirectShow.VideoCaptureDevice::OnNewFrame