请选择 进入手机版 | 继续访问电脑版

Hello Mat

 找回密码
 立即注册
查看: 1276|回复: 0

bytes 转 bitmap

[复制链接]

1278

主题

1504

帖子

90

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22549
发表于 2022-6-29 17:09:49 | 显示全部楼层 |阅读模式

  1. private static void cameraFrameCallback(ref Frame frame, IntPtr user_ptr)
  2.         {
  3.             try
  4.             {
  5.                 var bytes = Context.FrameToBytes(ref frame);

  6.                 Bitmap bitmap = new Bitmap((int)frame.Width, (int)frame.Height, PixelFormat.Format24bppRgb);
  7.                 int pos = 0;
  8.                 for (int y = 0; y < frame.Height; y++)
  9.                 {
  10.                     for (int x = 0; x < frame.Width; x++)
  11.                     {
  12.                         bitmap.SetPixel(x, y, Color.FromArgb(bytes[pos], bytes[pos + 1], bytes[pos + 2]));

  13.                         pos += 3;
  14.                     }
  15.                 }
  16.                 bitmap.Save($"{Guid.NewGuid():N}.png");
  17.             }
  18.             catch (Exception ex)
  19.             {
  20.                 System.Console.WriteLine(ex.Message);
  21.             }
  22.         }
复制代码




算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-3-28 20:38 , Processed in 0.196341 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表