protected OnNewFrame ( |
||
image | New frame's image. | |
Résultat | void |
// 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); }