It looks like you need to learn a bit more on what .NET and CLR do and how it's different from native code.
This is managed platform, so you cannot interpret objects (I mean "object" in the most general sense of this word here, both reference and value objects, including primitive ones) as objects in real memory and perform direct operations with them by copying them in memory. You simply don't have direct access to memory.
I don't even ask how you P/Invoke
memcpy
— it does not matter. Basically, you have two ways to work with bitmap memory: you can fix memory and get access to memory pointers, which is only possible in unsafe mode, or you can use the method
System.Runtime.InteropServices.Marshal.Copy
to work with
IntPtr Scan0
.
Please see the code sample from the MSDN help page for
System.Drawing.Bitmap.LockBits
:
http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx[
^].
See also
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.aspx[
^].
For using unsafe option of the .NET project and pointers for array copy operations, see
http://msdn.microsoft.com/en-us/library/28k1s2k6.aspx[
^].
See also for unsafe and pointers in .NET in general:
http://msdn.microsoft.com/en-us/library/t2yzs44b.aspx[
^].
—SA