|
- private static void cameraFrameCallback(ref Frame frame, IntPtr user_ptr)
- {
- try
- {
- var bytes = Context.FrameToBytes(ref frame);
- Bitmap bitmap = new Bitmap((int)frame.Width, (int)frame.Height, PixelFormat.Format24bppRgb);
- int pos = 0;
- for (int y = 0; y < frame.Height; y++)
- {
- for (int x = 0; x < frame.Width; x++)
- {
- bitmap.SetPixel(x, y, Color.FromArgb(bytes[pos], bytes[pos + 1], bytes[pos + 2]));
- pos += 3;
- }
- }
- bitmap.Save($"{Guid.NewGuid():N}.png");
- }
- catch (Exception ex)
- {
- System.Console.WriteLine(ex.Message);
- }
- }
复制代码
|
|