Answer the question
In order to leave comments, you need to log in
Passing HBitmap from Delphi dll to C# application?
Welcome all. The problem is the following.
It is necessary to pass the path to the file to the Delphi dll, the dll must draw a bitmap from this file and pass the HBitmap to the C# application. There is a TImage in the dll, I draw on it and pass TImage.Picture.Bitmap.Handle. In the receiving application, I draw the image using HBitmap. But it is not drawn, my pictureBox.Image is filled with just a white background, but if before drawing and passing the handle to the dll, put ShowMessage or show a modal form, everything is normally drawn. What is the problem?
Tried to pass a pointer to the first byte of the image in memory and the size of the image. The same.
And tell me, you can somehow change the following code, so as not to collect the array by bytes, but immediately get it.
byte dd;<br/>
byte* ddd = ⅆ<br/>
ddd = (byte*)LibWrap.TRGOpen("D:\\111.trg", ref size);<br/>
byte[] img = new byte[size];<br/>
for (int i = 0; i < size; i++)<br/>
{<br/>
byte t = *(ddd + i);<br/>
img[i] = t;<br/>
}<br/>
public unsafe class LibWrap<br/>
{<br/>
[DllImport("TRGA.dll")]<br/>
public static extern void* TRGOpen([MarshalAs(UnmanagedType.LPStr)] string str, ref int size);<br/>
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question