Marshal提供了一个方法集,这些方法用于分配非托管内存、复制非托管内存块、将托管类型转换为非托管类型,此外还提供了在与非托管代码交互时使用的其他杂项方法。
命名空间:System.Runtime.InteropServices
程序集:mscorlib(在 mscorlib.dll 中)
c#中Marshal.Copy方法的使用
Marshal.copy()方法用来在托管对象(数组)和非托管对象(IntPtr)之间进行内容的复制。
if (curBitmap != null)
{
//位图矩形
Rectangle rect = new Rectangle(0, 0, curBitmap.Width, curBitmap.Height);
//以可读写的方式锁定全部位图像素
System.Drawing.Imaging.BitmapData bmpData = curBitmap.LockBits(rect, System.Drawing.Ima