<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">了解yv12的编码格式,将函数放在回调函数中实现,截获视频流,方便二次开发。</span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">
</span>
private Image<Bgr,byte> ToBgrImage(IntPtr pBuf, int nSize, int nWidth, int nHeight) //size608256 wid704 height506
{
//分配内存通道并设置格式(这里必须使用bitmap进行分配)
Bitmap bmp = new Bitmap(nWidth, nHeight, PixelFormat.Format24bppRgb);
Rectangle rect = new Rectangle(0, 0, nWidth, nHeight);
BitmapData bmpdata = bmp.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
//对内存中的数据尽心分配
unsafe
{