private void CopyTextureDataToImage(ImageData destination, DataRectangle source) { int pitch = source.Pitch; /* Todo: be portable to 64bit :) */ int destDataPointer = destination.Scan0.ToInt32(); int sourceDataPointer = source.Data.DataPointer.ToInt32(); int rowByteSize = destination.Stride; int sourceByteOffset = 0; for (int y = 0; y < Height; ++y) { var destPointer = new IntPtr(destDataPointer + (y * rowByteSize)); var sourcePointer = new IntPtr(sourceDataPointer + sourceByteOffset); CopyMemory(destPointer, sourcePointer, rowByteSize); sourceByteOffset += rowByteSize + (pitch - rowByteSize); } }
public void Unlock(ImageData imageData) { imageData.Unlock(); }