[release] Delphi SDK 1.2

Finally completed to transfer/ translation of the SDK 1.2 / 1.3 to Delphi.

I've tested all the commands and they are all working with 1.2 and 1.3 (1.3 at least the test version that Andreas sent me so that I could debug a few problems between Delphi and C++, Thank you Andreas)

I fixed a few commands and added a bunch of new commands. I've tagged //AVE 1.2 to all the new commands I've added.

Also included an example on how to make a property sheet in Delphi for AveDesk and how to list / enumerate skins in Delphi.

There is a couple of new commands that are targeted to 1.3, but those will be review again once Andreas completes all work on 1.3. These have been marked has not implemented or 1.3

Now that the SDK is updated, it will take very little time for me to upgrade it to 1.3 in the future, when the final version is completed. If any new commands are created.

Also, included in the SDK is the latest DLL that sadly is needed to convert the GDIBitmps between Delphi and C++. This converting is very fast and shouldn't affect performance in Delphi. Thank you Andreas for helping me out in C++.

Have a nice day.

#294863

Excellent news, i`ll make sure this gets in the spotlight on the front page ;)

#294876

Wow.... this is way the heck over my head. Anyways, I should probably say good job!

#294887

Small update to the SDK.

This SDK works with 2005 Delphi. Due to a change in 2005 a small fix was added so that there isn't any Access Violation when unloading the DLL.

DelphiDeskletSDK.zip

Attachment: DelphiDeskletSDK.zip

#298451

Alas, Thank button can be pressed just one time :). Thank you, pcm. I'll test it for a few days and then I'll say something worthy here. Meanwhile - thank you one more time.

#298537

Great Job man ! ;)

#298540

I just downloaded the Delphi SDK, thanks a lot for your work pcm (now I don't have to spend time doing it my self)...

Is the source for aveimg.dll available? I would like to know if it would be possible to work around it but I don't understand exactly why it's needed (please elaborate a bit on the Delphi -> C++ GDI+ conversion subject)...

#315269

I can email you the source if you want. The problem is that GDI+ in Delphi and GDI+ in C++ Object structure is different. Talking about the TGPBitmap object. C++ has the object allocated different in memory, so when I pass that object to Avedesk, it doesn't work. The aviimg basically converts the "Data" over and returns the pointer to the C++ GDI + Bitmap object.

Also, Once 1.3 avedesk is posted, I will be posting the SDK too.. I've been maintaining all the changes, but haven't posted it since there is no 1.3 released yet :P

#315277

Ok, conversion done by a dll is a convenient solution especially if you want to keep the interface consistent with the one in C++. But why not include conversion routines in the Delphi SDK (or is it impossible to do the conversion in Delphi before passing it on)? It would then be up to the developer to use the conversion routines (additional housekeeping but no dependencies to an external dll) or let the dll do the conversion (with the added requirement of including the dll in the distribution). Or have I totally missed the point (I have to read up on GDI+ and Delphi because I haven’t used GDI+ from Delphi yet).

I guess you already taken a look at the following sites:

http://www.progdigy.com/modules.php?name=gdiplus

http://www.lummie.co.uk/content/view/52/42/

#315287

I wish I could include the conversion in Delphi DLL, but I can't. See, avedesk needs a pointer to a GDI Bitmap. Delphi's TGPBitmap just isn't the same :( The routines are the same, but since the desklet isn't actually doing the drawing, its avedesk that does it, you need to send avedesk the C++ GDI Bitmap.

At one point, I even considered putting the DLL into the Delphi DLL and have it self extract the dll and use it.. but it just got messy that way. :/

I spent lots of time with Andreas trying to find a solution, but in the end the only way it was possible was another dll that converts it. If there was away that the Delphi could give an exact C++ structure then this wouldn't be needed. If you can figure that part, you would be my new hero. Just keep in mind that TGPBitmap isn't the same in the memory space has the C++ version. Probably has to do with the way the class is defined in delphi vs C++.

To be honest, I haven't spent any time on it since that solultion was placed. Been too busying with my desklet so it will be ready for the next version of avedesk.

I was aware of the first website since thats where I got the pas files for GDI+, didn't know about the second website.

At the moment the dll is needed until a better solution is found. Andreas will be including the dll in 1.3 so we will not need to worry about install it. And I agree with him about not including the commands in avedesk. Makes things more modular plus allows us "Delphi" guys to maybe find a even better solution.

Again, the only problem is that TGPBitmap is not the same has the GPBitmap of C++. So when you pass the pointer of TGPBitmap to C++ and it tries to read the properties, it BLOWS UP! AveImg.dll fixes that problem because I compiled it in C++. I send the DATA of the bitmap to the dll it returns me a pointer to a C++ GDI Bitmap that was created with the data I passed. And viceversa. C++ GDIBitmap to Delphi TGPBitmap.

:)

#315290

I have been looking a bit in the source of the Delphi GDI+ wrapper... the TGPBitmap looks like a container class for something else... have you tried passing the nativeImage field to Avedesk ? GpImage, GpBitmap etc etc may be the pointers to the real (C++ because they are created by the GDI+ dll) objects in memory :)

[edit] mmmh I'm almost sure - all the TGPBitmap methods call the gdi+ function passing nativeImage as the pointer...

#315302

Tried that already after I had done the dll and of course no go. :(

Your right about the GPImage is used and passed, but C++ GDI+ also wrappers around that too. And AveDesk expects the C++ GDI+ Wrapper and not the actual GPImage.

#315308

Intriguing... I have to try to find some time and setup a test project. I will try to talk to some C++ gurus at work (that also works with Delphi). Maybe they stumbled on something similar in the past... I have a hard time believing that it wouldn’t be possible to work it out in plain Object Pascal (or tricking Delphi to do something that would satisfy the host application regardless of language used). Could you please mail me the dll source? Maybe it might help to fully understand the problem and to setup a test project…

pcm, you got a PM...

#315318

I took some time (not much) and went trough the SampleDesklet. I guess (from what I have read so far in this thread) that the main problem is passing the TGPBitmap data to the host application (AveDesk). I haven’t programmed towards GDI+ before and to be honest I thought that it was a COM interface. Browsing trough the source (especially the GDIPAPI unit) gave me the impression that it was a classic Windows DLL-interface.

Anyway, the class hierarchy of TGPBitmap is the following (as I see it):

TObject->TGdiplusBase->TGPImage->TGPBitmap

No wonder why AveDesk is choking on it. The TObject is adding overhead that makes no sense to any other development environment than Delphi (or maybe other Borland products).

Take a look at the following code snippet from the GDIAPI unit:

class function TGdiplusBase.NewInstance: TObject;

begin

Result := InitInstance(GdipAlloc(ULONG(instanceSize)));

end;

What is going on? The function is supposed to return a TObject (witch is a pointer to the root object class in Borland’s VCL). The function is using the GDI+ function GdipAlloc (used to allocate some memory for GDI+ objects) and then InitInstance to initiate it to all zeros (Delphi style). I don’t know if this is a good idea if the object is supposed to be passed back to a C++ application? I would prefer to use pointers to Windows native object types (or structs etc) and maybe wrap a TObject around that (to encapsulate it in a native Delphi VCL object or component).

I don’t have time to dig deeper into this tonight but it must be a better way to do this…

Godnight...

#315327

Yup.... you now understand my problem with passing the TGPBitmap of delphi to C++.. Its just not the same thing. But the GpImage is the same, since it calls the dll routines to get a pointer to the GpImage and that is what is used in all the GDI Commands.

You also need to look at the C++ code and you'll understand even more whats going on. C++ does the same thing too, but C++ style.

I don't like it myself, but I just can't see any possible way to pass a Image C++ (Which is C++ object that wraps GDI+ stuff) from delphi with out using a "middle man" to do it.

#315352

it may be useful to dump a TGPBitmap object on disk and an equivalent C++ object created in the same way to see how much they differ... I'd love to take a look at them if you can send me a couple (I have only delphi here :slant: )

#315355

If your talking about memory dump of the actual TGPBitmap and the C++ version I'm not sure how to do that in C++. My C++ skills are limited, but I could do it in Delphi :P

#315366

I'd say: Try passing the bitmap with the autodestroy set to false so that AveDesk won't try a C++ style delete on it after it has updated the image. The wrapper C++ object's destructor may be causing the problem.

#315420

Its not the destroy. I traced it with the debugger in AveDesk (Yes I got the source, Andreas gave it me to so I can try to trace it). It crashes before that. See, avedesk will call other commands / properties of the Image and they are not in the correct memory space, so it goes boom. :( At least that is what I remembed. I can double check again, it was a few months ago (3-4). I have a hard timer remembering yesterday :P

#315457

I see. So you'll have to have a C++ object passed. Complete with VTBL (Bitmap inherits from Image inherits from GdiplusBase - if you have Borland C++, you can perhaps recreate it somehow and link it to the Delphi as a static library?

#315466

That's what I'm doing with the other dll. Its linked (static in 1.3) to aveimg.dll. Aveimg.dll has very little code (20k) all it does is create a image from the gpimage(1.3) or data(1.2) to a c++ object then returns a pointer to that object back to delphi. I then pass that same pointer back to AveDesk.

#315470

I've tried to compile the desklet example here, but my delphi 2005 can't recognize GDIPAPI , GDIPOBJ units. Does somebody know why?

#317776

The SDK will compile with 2005 Delphi. All my work on the AveScripter is in 2005 Delphi. All you need is to download the GDI api and put it in your library path.

To download it just go to this site:

http://www.progdigy.com/modules.php?name=gdiplus

#317917