C#控制明美显微镜,IntPtr转 Bitmap

        static bool CopyMenImage(ref dvpFrame frame, IntPtr buff, out Bitmap dst)
        {
            try
            {
                PixelFormat pixeFormat = PixelFormat.Format24bppRgb;

                switch (frame.format)
                {
                    case dvpImageFormat.FORMAT_BGR24:
                        pixeFormat = PixelFormat.Format24bppRgb;
                        break;
                    case dvpImageFormat.FORMAT_BGR32:
                        pixeFormat = PixelFormat.Format32bppRgb;
                        break;
                    case dvpImageFormat.FORMAT_BGR48:
                        pixeFormat = PixelFormat.Format48bppRgb;
                        break;
                    default:
                        throw new Exception("该方法未实现 " + frame.format + " 目标图像格式的转换, 请设置工业相机目标图像格式为 BGR24/BGR32/BGR48 格式!");
                }

                byte[] bBuff = new byte[frame.uBytes];
                dst = new Bitmap(frame.iWidth, frame.iHeight, pixeFormat);
                BitmapData bmpData = dst.LockBits(new Rectangle(0, 0, dst.Width, dst.Height), ImageLockMode.ReadWrite, pixeFormat);
                Marshal.Copy(buff, bBuff, 0, bBuff.Length);
                Marshal.Copy(bBuff, 0, bmpData.Scan0, bBuff.Length);
                dst.UnlockBits(bmpData);

            }
            catch (Exception)
            {
                dst = null;
                return false;
            }
            finally
            {

            }

            return true;
        }