internal static void CopyStreamToSurface(SharpDX.DataBox dbox, Surface dst, Rectangle rect) { IntPtr textureBuffer = dbox.DataPointer; IntPtr dstPointer = dst.GetPointPointer(rect.Left, rect.Top); if (rect.Width == dst.Width) { CopyMemory(dstPointer, textureBuffer, rect.Width * rect.Height * COLOR_SIZE); } else { int length = rect.Width * COLOR_SIZE; int dstStride = dst.Stride; int rectBottom = rect.Bottom; for (int y = rect.Top; y < rectBottom; y++) { CopyMemory(dstPointer, textureBuffer, length); textureBuffer = IntPtr.Add(textureBuffer, length); dstPointer = IntPtr.Add(dstPointer, dstStride); } } }
private unsafe void CopyRois(Rectangle[] rois, Surface dest, Surface source) { int COLOR_SIZE = Marshal.SizeOf(typeof(ColorBgra)); foreach (Rectangle copyRect in rois) { int length = copyRect.Width * COLOR_SIZE; for (int y = copyRect.Top; y < copyRect.Bottom; y++) { CopyMemory(dest.GetPointPointer(copyRect.Left, y), source.GetPointPointer(copyRect.Left, y), length); } } }