The Daily Click ::. Forums ::. Klik Coding Help ::. calldll issues
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th February, 2005 at 16:54:25 -

is there anyone here who is good with the calldll extension? (and for everybody expecting this to be a typical newbie problem, this hopefully isnt just a "how do i use calldll" type question, as i do more or less understand how the extension works.)


i'm intending to use a free library called "freeimage" (easily found on google) which seems to be able to do lots of very smart things with images. i'm having some problems though.

i've established that the functions are not named exactly as stated in the manual by using dependancy walker - the function to load an image "FreeImage_Load" is actually "_FreeImage_Load@12" for example. the arguments in the manual are described correctly and i'm confident that this works as i dont get any error messages and the app doesnt die on me.

however, when i try something else, such as saving the loaded image, the app crashes (just disappears - no error messages, nothing)

i dont imagine too many people use this dll or are about to download it just to help me (although i think a lot of people might find it useful themselves) but...

is there some significance to the manner in which something is broken? (error message / crash app / nothing happening). so far i get the impression an error message means i'm doing something wrong, and crashing means the dll or mmf is doing something wrong?

are there some limitations in mmf or the calldll extension which may prevent certain functions from working?

anyone know where i might download a copy of the calldll documentation?

any other useful suggestions re. calldll?

failing that, anyone happen to know of any graphic related dlls (capable of format conversion, rotation etc)

 
n/a

Long John Kickbag



Registered
  26/08/2002
Points
  148
9th February, 2005 at 18:12:25 -

The library will probably have exported pointers to the functions without the _ and @parameters_size stuff so something like FreeImage_Load should work.

It can be very hard to handle structures in MMF, so its best if you try to avoid functions that take structures as pointers or return structures.

If the function doesn't take easy to handle parameters then I suggest you just create your own wrapper DLL to call the functions.

 
Resize! - www.clicksplat.com/comparison.html

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
9th February, 2005 at 19:19:57 -

Just a note, the function names in the manual are the names that have been mapped out in the header (.h) file for C/C++ apps. When you compile a DLL in MSVC (and I think GCC) it adds the _ and @## (## is the number of bytes taken as argument; 12 bytes is 3 arguments). Since you're calling it in a system it wasn't designed for, you have to use the raw names for things

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th February, 2005 at 20:03:34 -

i see - so a function needs 1 argument for each 4 bytes. this could be part of the problem - the function for saving an image has a 16 after it but the manual only lists 3 arguments. i'll try using 0s for a few of the extra arguments and see if i can get away with it on any of them (manual suggests you can use them instead of non-essential arguments so i think its worth a try)
failing that, im going to have to decide its just not a suitable dll for using in mmf.
dont think i'll be building a wrapper dll - if i could program i wouldnt be needing mmf

thanks

 
n/a

Long John Kickbag



Registered
  26/08/2002
Points
  148
10th February, 2005 at 07:20:36 -

No the function names are exported in the DLL (at least with the only method I'm familiar with which is using a def file).

A parameter isn't necessarily 4 bytes, thats just a common amount because longs and pointers are that size. The bit at the end is just the size of all the parameters. It might be that one of the parameters is a structure with two longs in it or something.

You could try inputting structures by inputting the information in them as a load of integers since it's all just put onto the stack (it's left for the function being called to distinguish between different parameters).

 
Resize! - www.clicksplat.com/comparison.html

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
10th February, 2005 at 07:58:56 -

When MSVC compiles DLLs, it expands all parameters to 4 bytes, even if they're only 1,2 or 3 byte bits of data

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Long John Kickbag



Registered
  26/08/2002
Points
  148
10th February, 2005 at 11:10:56 -

Heh didn't know that but there can still be parameters that are bigger than 4 bytes.

 
Resize! - www.clicksplat.com/comparison.html

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
10th February, 2005 at 11:48:09 -

i think i know why it wouldnt work.
the following is from the manual;

// this code assumes there is a bitmap loaded and
// present in a variable called ‘bitmap’
if (FreeImage_Save(FIF_BMP, bitmap, “mybitmap.bmp”, 0)) {
// bitmap successfully saved! }

This shows an extra argument "bitmap" not described in the main text, which it calls a variable.
The problem is that i cant set a variable when i load an image.

Looking again at the example in the manual, i would guess that the "*bitmap" at the beginning is to set the variable.
Is there any kind of an equivalent in mmf or is this just impossible?

FIBITMAP *bitmap = FreeImage_Load(FIF_BMP, “mybitmap.bmp”, BMP_DEFAULT);

if anyone is volunteering to make an extension for it then go for it= i guess its a bit more involved than copying and pasting a C++ example into an extension template though, so its beyond me

 
n/a
   

Post Reply



 



Advertisement

Worth A Click