Solved

TBitmap To C.

Posted on 2004-03-22
9
346 Views
Last Modified: 2010-04-05
Hi,
    I need to pass a TBitMap to a C DLL. How can I do this? Is there a compatible type in C (Microsoft Visual C)? Is TBitmap a wrapper class based on some win32 data structure?

Thanks.
0
Comment
Question by:limin123
  • 5
  • 4
9 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 10647885
it should be enough to forward the handle
0
 
LVL 1

Author Comment

by:limin123
ID: 10657898
How do I forward the handle to the C DLL?

I tried using TBitmap.Handle to get a handle to the Tbitmap object and pass this to a C DLL which declares the input parameter as HBitMap but it didn't work. Do you know why this is so?
0
 
LVL 1

Author Comment

by:limin123
ID: 10657915
I meant HBITMAP instead of HBitMap in the comment above.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 10657943
?? the handle is the HBITMAP-type

did you freed your TBitmap after/before you call the dll?
(do not free it until the dll is ready)

meikl ;-)
0
 
LVL 1

Author Comment

by:limin123
ID: 10658131
Thanks for the quick response.

if object ABC is a TBitMap object, does ABC.Handle return a HBITMAP?

The TBitMap was freed only after the DLL was called.

Thanks.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10658202
>if object ABC is a TBitMap object, does ABC.Handle return a HBITMAP?

yes,

from delphi helpfile:

Provides access to the Windows GDI bitmap handle for accessing the GDI bitmap object.

Delphi syntax:

property Handle: HBitmap;


Description

Use Handle to call a Windows API function that requires the handle of a bitmap object. Pass Handle as the bitmap handle parameter to these functions.

Handle is the HBITMAP encapsulated by the bitmap object. Avoid grabbing the handle directly since it causes the HBITMAP to be copied if more than one TBitmap shares the handle.
0
 
LVL 1

Author Comment

by:limin123
ID: 10663988
Here's my delphi wrapper. myPic is a TBitmap object.
result      := TEST_DLL( HBITMAP(myPic.Handle) );

and here is the C function declaration:

IMGPRO_API IMGP_RESULT Test(HBITMAP i_HBmp);

I am still getting access violation.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10667472
i saw, you posted an additional q.

is the problem now solved?

meikl ;-)
0
 
LVL 1

Author Comment

by:limin123
ID: 10673295
Hi Thanks a lot.
Yes the HBITMAP problem has been solved.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question