The CopyMemory P/Invoke declaration is correct so the problem don't come from
that.
Assuming that the BitmapData object point to a locked bitmap data, the memory
access problem can't come from the source part.
So the problem is the destination part. Put some breakpoints in your code and
check if the computed value is correct. The ipDest calculation is not 64 bits
friendly. Use ToInt64 instead. This will works for both system kind. You can
also make this calculation with some pointer arithmetic (void* can explicitly
be casted to IntPtr).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This looks like a very simple debugging issue. Just because you are using
DirectShow doesn't mean you should forget everything you ever learned about
how to debug code.
Hi,
I have this error in "CopyMemory".
Attempted to read or write protected memory. This is often an indication that
other memory is corrupt.
region API
private static extern void CopyMemory(IntPtr Destination, IntPtr Source, uint
Length);
endregion
IntPtr ipSource = m_bmdLogo.Scan0;
IntPtr ipDest = (IntPtr)(pBuffer.ToInt32() + ((w * 3) * N));
CopyMemory(ipDest, ipSource, ((uint)m_bmdLogo.Stride));
please help regarding this issue
Thanks !
dhemittal@gmail.com
The CopyMemory P/Invoke declaration is correct so the problem don't come from
that.
Assuming that the BitmapData object point to a locked bitmap data, the memory
access problem can't come from the source part.
So the problem is the destination part. Put some breakpoints in your code and
check if the computed value is correct. The ipDest calculation is not 64 bits
friendly. Use ToInt64 instead. This will works for both system kind. You can
also make this calculation with some pointer arithmetic (void* can explicitly
be casted to IntPtr).
This looks like a very simple debugging issue. Just because you are using
DirectShow doesn't mean you should forget everything you ever learned about
how to debug code.
Try adding this just before the CopyMemory call:
Debug.WriteLine("{0} {1} {2}", ipDest.ToInt32(), ipSource.ToInt32(),
((uint)m_bmdLogo.Stride));