如何在没有 unsafe 修饰符的情况下重写此代码?
var bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
var size = Math.Abs(bmpData.Stride) * bitmap.Height;
var stream = new UnmanagedMemoryStream((byte*)bmpData.Scan0, size));