private void flipImageYAxis(IntPtr source, IntPtr dest, int stride, int height, int size)
{
long top, bottom;
byte[] buffer;
long topP;
long bottomP;
long rowBytes;
top = 0;
bottom = height - 1;
rowBytes = stride;
var mData = new byte[size];
Marshal.Copy(source, mData, 0, size);
buffer = new byte[rowBytes];
while (top < bottom) {
topP = top * rowBytes;
bottomP = bottom * rowBytes;
/*
* Save and swap scanlines.
*
* This code does a simple in-place exchange with a temp buffer.
* If you need to reformat the pixels, replace the first two Array.Copy
* calls with your own custom pixel reformatter.
*/
Array.Copy (mData, topP, buffer, 0, rowBytes);
Array.Copy (mData, bottomP, mData, topP, rowBytes);
Array.Copy (buffer, 0, mData, bottomP, rowBytes);
++top;
--bottom;
}
Marshal.Copy(mData, 0, dest, size);
}