is there any better way to copy block of unmanaged memory to other block of
unmanaged memory than looping through individual bytes or integers ?
Marshal.Copy only copies data between managed and unmanaged memory. Buffer
class also doesn't do the job.
the second part of quetion is maybe i don't need to copy data in this method
at all ? but
bitmapData.Scan0 = pData;
creates memory leaks. after calling this method for several hundred or
thousand times i run out of memory :]
public unsafe Bitmap GetFrame(int frameNumber)
{
IntPtr pFrame = Avifil32.AVIStreamGetFrame(this.pfg, frameNumber);
Win32.BITMAPINFOHEADER bif =
(Win32.BITMAPINFOHEADER)Marshal.PtrToStructure(pFrame,
typeof(Win32.BITMAPINFOHEADER));
IntPtr pData = new IntPtr(pFrame.ToInt32() + bif.biSize);
Bitmap bitmap = new Bitmap(this.Width, this.Height);
BitmapData bitmapData = bitmap.LockBits(new Rectangle(Point.Empty,
bitmap.Size), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
uint* p1 = (uint *)bitmapData.Scan0.ToPointer();
uint* p2 = (uint *)pData.ToPointer();
for (int i = 0; i < bitmapData.Stride * bitmapData.Height; i += 4)
*(p1++) = *(p2++);
bitmap.UnlockBits(bitmapData);
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
return bitmap;
}
thanks
Mattias Sj?gren - 27 Sep 2004 22:34 GMT
>is there any better way to copy block of unmanaged memory to other block of
>unmanaged memory than looping through individual bytes or integers ?
Call kernel32!RtlMoveMemory through P/Invoke
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.