How to pass Bitmap to a DLL function in C ++ and Delphi?

I want to create DLL plugins for use with Delphi and other languages ​​(mainly C ++). How to transfer bitmap images in C ++ and Delphi? Could this be a Delphi TBitmap handle? A C ++ program should be able to decode it using WinApi, right?

+3
source share
1 answer

You cannot pass a Delphi object TBitmap, as this only makes sense for Delphi code. What you need to pass HBITMAPis a Windows bitmap descriptor.

The Delphi class TBitmapis just a Windows bitmap wrapper and may contain descriptors HBITMAP. The thing you need to keep track of is ownership of these pens.

If you have Delphi TBitmap, you can get HBITMAPit by calling the ReleaseHandlemethod TBitmap. The handler returned ReleaseHandleis no longer owned and controlled by the object TBitmapthat you want. You pass this handle to C ++ code and let it become the owner. He is responsible for removing this pen.

The documentation for ReleaseHandlesays:

Returns the handle to the bitmap so that the TBitmap object no longer knows about the handle.

ReleaseHandle, . , ( ) -.

Delphi HBITMAP ++ . , Handle TBitmap.

, , HBITMAP.

+9

Source: https://habr.com/ru/post/1685248/


All Articles