OnNewFrame() protected méthode

Notifies client about new frame.
protected OnNewFrame ( Bitmap image ) : void
image System.Drawing.Bitmap New frame's image.
Résultat void
Exemple #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);
            }
Exemple #2
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);
         parent.OnNewFrame(bitmap);
         bitmap.Dispose();
     }
     return(0);
 }