i am trying to copy the pixels of a Bitmap into a DirectX texture. its simple to get the IntPtr’s from both, but how do i copy the pixel data efficiently?
var data = FBitmap.LockBits(..)
var rect = texture.LockRectangle(0, LockFlags.None);
IntPtr from = data.Scan0;
IntPtr to = rect.Data.DataPointer;
//copy data
texture.UnlockRectangle(0);
FBitmap.UnlockBits(data);
i tried to use Marshal.Copy but it need the pixels as an array and i would like to avoid another copy of course.
You could use the Windows API CopyMemory – Alias “RtlMoveMemory”. Much faster than all of that LockBits stuff…
http://www.pinvoke.net/default.aspx/urlmon/CopyMemory.html