[Mono-dev] Copy RGB buffer from Bitmap to unmanaged memory

Jean Carrive jcarrive at ina.fr
Thu Dec 22 06:05:03 EST 2005


 
    Hello everyone,
 
I am trying to copy a RGB buffer coming from a Bitmap object to a C buffer
under Linux, in order to do some image processing. I use "embedding" stuff,
and I have a C program calling DotNet methods.
 
Here is the code I wrote in C#, which is called from the C side, and which
uses the Marshal.Copy(...) method :
 
public void WriteRGB(IntPtr LinuxBuff)
{
	System.Drawing.Rectangle r = new System.Drawing.Rectangle(0,0,
bitmap.Width, bitmap.Height);
	BitmapData bd = bitmap.LockBits(r, ImageLockMode.ReadOnly,
PixelFormat.Format24bppRgb);
	IntPtr[] ptTab = new IntPtr[1];
	ptTab[1] = bd.Scan0;
	Marshal.Copy(ptTab, 0, LinuxBuff, r.Width*r.Height*3);
	bitmap.UnlockBits(bd);
}

First, I don't know if it the right way to do this, and, second, under Mono
I get the following error :
Unhandled Exception: System.MissingMethodException: Method not found:
'System.Runtime.InteropServices.Marshal.Copy'.

Could anyone help ?

Regards,
Jean




More information about the Mono-devel-list mailing list