Insider1984
Technical User
We are creating a C# app that needs to copy an image (or rather a (pointer + image size) to another memory location. Currently we are using IntPtr or byte* to do this in a for loop for each pixel. Apparently this is really slow compared to the old memcpy of the C++ C world.
A quick search finds that Buffer.BlockCopy seems to be the same style of function as memCpy. The problem is that it takes an Array not our current IntPtr.
Any advice on a faster approach?
=====================
Insider
4 year 'on the fly' programmer
C, C++, C#, MFC, Basic, Java ASP.NET
A quick search finds that Buffer.BlockCopy seems to be the same style of function as memCpy. The problem is that it takes an Array not our current IntPtr.
Any advice on a faster approach?
Code:
//lock bits
byte* outPtr = (byte*)outData.Scan0;
byte* inPtr = (byte*)inputImagePointer;
//Buffer.BlockCopy(inPtr, 0, outPtr, 0, (width * height));
for (int i = 0; i < (width * height); i++)
{
*outPtr = *inPtr;
outPtr++;
inPtr++;
}
//unlock bits
=====================
Insider
4 year 'on the fly' programmer
C, C++, C#, MFC, Basic, Java ASP.NET