The Delphi class is TBitmapvery different from the .NET class Bitmap. They are incompatible with each other, and none of them is safe for interoperability.
Instead, you will have to use a raw Win32 handle HBITMAP.
function LensFlare(Bitmap: HBITMAP; X, Y: Int32; Brightness: Real): HBITMAP; StdCall;
Begin
// ...
Result := Bitmap;
End;
[DllImport("ImageProcessor")]
static extern IntPtr LensFlare(PtrInt bitmap, int x, int y, double Brightness);
[DllImport("gdi32.dll")]
static extern bool DeleteObject(IntPtr hObject);
private void button1_Click(object sender, EventArgs e)
{
Bitmap b = new Bitmap(@"d:\a.bmp");
IntPtr hbmp = LensFlare(b.GetHbitmap(), 100, 100, 50);
try {
pictureBox1.Image = Image.FromHbitmap(hbmp);
}
finally {
DeleteObject(hbmp);
}
}