How to use type TBitmap32 (Delphi) in a DLL called in C ++?

0

Hello

I need to create a DLL in Delphi , to use it in a program written in C ++ . This DLL should manipulate an image (obtained through the path passed as function parameter). However, I'm having trouble loading the image into the DLL ; the program crashes when there is any call related to the image. I'm using a variable of type TImage32 ( img : TImage32 ); this variable will be assigned a TBitmap32 ( img.Bitmap := TBitmap32.Create ), and finally the image should be loaded using img.Bitmap.LoadFromFile(path) .

Tests I've done:

  • I ran the DLL , from C ++ , with parts that do not use images. This worked correctly ;

  • I ran the same excerpt, inserting the line img.Bitmap := TBitmap32.Create; . This failed in the above line .

Is there any trick for using DLL images in Delphi?

OBS1: I did not post code, because this is not really the problem.

OBS2: My experience with Delphi is null as well as creating DLL .

Thank you!

    
asked by anonymous 08.08.2018 / 02:19

1 answer

0

It seems to be using a third-party library, at that point it's tricky to help, but in theory it was built on the basis of TImage .

If this is the case, the creation is with an error and the problem is exactly there, an exception will be generated and its DLL has no treatment.

Try using the TImage native following this format:

var
  vTeste: TImage;
begin
  vTeste := TImage.Create(Self);
  vTeste.Picture.Bitmap.LoadFromFile('C:\temp\Teste.bmp');

It worked normally here.

Note that we must first create the Object, then feed its properties. In your case posted I believe the problem is exactly this!

    
31.08.2018 / 16:41