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

OnNewFrame() protected method

Notifies client about new frame.
protected OnNewFrame ( Bitmap image ) : void
image System.Drawing.Bitmap New frame's image.
return void
        protected 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

Esempio n. 1
0
            // Callback method that receives a pointer to the sample buffer
            public int BufferCB(double sampleTime, IntPtr buffer, int bufferLen)
            {
                if (parent.NewFrame != null)
                {
                    // create new image
                    System.Drawing.Bitmap image = new Bitmap(width, height, PixelFormat.Format24bppRgb);

                    // lock bitmap data
                    BitmapData imageData = image.LockBits(
                        new Rectangle(0, 0, width, height),
                        ImageLockMode.ReadWrite,
                        PixelFormat.Format24bppRgb);

                    // copy image data
                    int srcStride = imageData.Stride;
                    int dstStride = imageData.Stride;

                    unsafe
                    {
                        byte *dst = (byte *)imageData.Scan0.ToPointer( ) + dstStride * (height - 1);
                        byte *src = (byte *)buffer.ToPointer( );

                        for (int y = 0; y < height; y++)
                        {
                            Win32.memcpy(dst, src, srcStride);
                            dst -= dstStride;
                            src += srcStride;
                        }
                    }

                    // unlock bitmap data
                    image.UnlockBits(imageData);

                    // notify parent
                    parent.OnNewFrame(image);

                    // release the image
                    image.Dispose( );
                }

                return(0);
            }
All Usage Examples Of AForge.Video.DirectShow.FileVideoSource::OnNewFrame