Accord.Video.DirectShow.VideoCaptureDevice.Grabber.BufferCB C# (CSharp) Method

BufferCB() public method

public BufferCB ( double sampleTime, IntPtr buffer, int bufferLen ) : int
sampleTime double
buffer System.IntPtr
bufferLen int
return int
            public int BufferCB(double sampleTime, IntPtr buffer, int bufferLen)
            {
                if (parent.NewFrame != null)
                {
                    // create new image
                    System.Drawing.Bitmap image = new Bitmap(width, height, this.pixelFormat);

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

                    // 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
                    if (snapshotMode)
                    {
                        parent.OnSnapshotFrame(image);
                    }
                    else
                    {
                        parent.OnNewFrame(image);
                    }

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

                return 0;
            }
        }
VideoCaptureDevice.Grabber