Jump to content
Excelsior Forums
ILUsion

GDI+ problems

Recommended Posts

Hi everybody,

I'm experiencing a little problem with modula. I'm trying to use the GDI+-library in a Win32 Modula 2 application, but actually I don't have any idea how to start with the implementation. I've read most of the interesting parts of different manual, but it doesn't really say how to do this. I've also tried to feed both gdiplus.h and gdiplussflat.h to H2D, which returns very strange error messages as if it doesn't understand anything about how C declares a procedure/function. I've also searched for about two days (Google, Google Code, SF.net, Yahoo, ...), but I haven't found anything useful yet.

I've also tried to feed gdiplus.dll to XLIB (multiple times), with which I have now generated a LIB-file, EDF-file and a general LIST. But, my main concern here is: there are only MODULES inside (which means, C++ objects, and I don't have any idea how to use them from my source code (which methods and fields it passes, what types they are, what names they have, ...)).

Another option would be using the dllRTS-module, but yet again, I don have any idea on how to use it (well, I know how to load the DLL, but how can I pass parameters to a function etc.)

So, if someone has an XDS-compatible DEF-file for GdiPlus (or even the SB Modula DEF could do perhaps after some conversions) or could help me in any possible way: all help is greatly appreciated !

Share this post


Link to post
Share on other sites

I'm currently thinking of implementing it the following way:

- make a DLL from Delphi which links to gdiplus.dll to wrap around the object-related edges of it, so I can use self-written (Object Pascal/Delphi) procedures which I can call from Modula

- manually make a DEF file for this DLL and just import it as normally (eventually with a LIB-file generated for optimalisation)

Do you think this might work? (And yes, I know, this isn't an optimal solution, but I currently see no reasonable other way which can be implemented in a short period of time).

Share this post


Link to post
Share on other sites

As far as I can recall, there once was a (deprecated) plain C API for GDI+. The C++ API used to be nothing more than a wrapper for that. You could try searching MSDN library.

Share this post


Link to post
Share on other sites

As far as I can recall, there once was a (deprecated) plain C API for GDI+. The C++ API used to be nothing more than a wrapper for that. You could try searching MSDN library.

I'm aware of this flat C headers, in any case, I have a C headers file (gdiplusflat.h or was it gidplus_flat.h)  for the GDI+ which doesn't use any object ori?nted facilities, but it also doesn't load in H2D, so it's currently worthless to me.

Update:

I've got it working by now :-) Only some minor bugs in it, but debugging isn't an issue.

Thank you, Dimych !

If anyone wants my code (DLL, LIB, DEF, Delphi Project etc.), feel free to ask (send a mail or something, but please not that it doesn't include all features, only the loading of pictures to a buffer, which gets drawn onto a from. The code is also not an example of bug-proof, as it uses Delphi OpenArrays with no form of checking the indexes (which you get to assign by yourself).

Share this post


Link to post
Share on other sites

As far as I can recall, there once was a (deprecated) plain C API for GDI+. The C++ API used to be nothing more than a wrapper for that. You could try searching MSDN library.

I'm aware of this flat C headers, in any case, I have a C headers file (gdiplusflat.h or was it gidplus_flat.h)  for the GDI+ which doesn't use any object ori?nted facilities, but it also doesn't load in H2D, so it's currently worthless to me.

Update:

I've got it working by now :-) Only some minor bugs in it, but debugging isn't an issue.

Thank you, Dimych !

If anyone wants my code (DLL, LIB, DEF, Delphi Project etc.), feel free to ask (send a mail or something, but please not that it doesn't include all features, only the loading of pictures to a buffer, which gets drawn onto a from. The code is also not an example of bug-proof, as it uses Delphi OpenArrays with no form of checking the indexes (which you get to assign by yourself).

Publish it on sourceforge.net and post link here  :)

Share this post


Link to post
Share on other sites

I don't think it is worth publishing on SF yet, as my code seems to contain a few bugs. But I do have an online space where you can consult this code (as this GDI+ code is part of a larger project, due in Modula-2). You can download the code at http://student.vub.ac.be/~egeerard/projects.html by clicking on the ZIP file for Chroma Trigger. (By the end of last week, I will also include the Subversion dump and the bugs should be resolved), the Delphi source code can be found in the gdiwrap directory, gdiwrap.dll is in the root (together with the import library), and the definition file can be found in the DEF directory. Feel free to build upon this code, I intend to release it under the Gnu Lesser Public License or Gnu Public License (to keep it's source free; and keep improvements to the code available to the public).

My implementation only implements the things our project needs (writing text, showing images, stretching images, getting image sizes) , but feel free to adjust the source code to your needs (if you haven't got the Delphi compiler, feel free to send your files back for compilation). You can consult the main source code of ChromaTrigger(which suffers still suffers from some major bugs, which are largely related to this delphi code, I guess) to get an idea how you should use my wrapper.

Any comment/remark/... is welcome, as it can only improve the project.

Perhaps I will make a SourceForge project of it, but currently I haven't got the time to manage such project. And to be honest, I don't think of modula-2 as thing I am willing to spend a lot of time with in the future (as I only needed to use XDS Modula-2 for a project for university, and I don't think of Modula-2 in general as a comfortable programming language).

Share this post


Link to post
Share on other sites

Perhaps I will make a SourceForge project of it, but currently I haven't got the time to manage such project. And to be honest, I don't think of modula-2 as thing I am willing to spend a lot of time with in the future (as I only needed to use XDS Modula-2 for a project for university, and I don't think of Modula-2 in general as a comfortable programming language).

Language might be as comfortable as you want.

My area of interest is Oberon more than Modula, but I can say, that both languages helps you make your program clearer than C(++)/Java.

Make some libs, publish your code, and your work we'll be more comfortable.

Share this post


Link to post
Share on other sites

I do understand that Modula is a better point to start from than C or java. I?m  actually an Object Pascal programmer. My main point of criticism on Modula is that it doesn't serve its programmer. You do get to work perfectly by the rules (e.g. not using a function (procedure with a return) if you don't handle the return etc.), but its specifications are too scattered: SB Modula is different from TS and XDS. I know that different implementations in any language will use different libraries, but with Modula sometimes entirely different syntax is needed. Also, being used to Delphi, when needing a float, you can enter a real (the compiler serves you by processing it in the right way, as there is only one way one could pass an integer as float (the other way round is something different: floor, ceiling or a plain round)).

It also feel that the XDS environment doesn't really serve its user; it works, but it sometimes is a hell to understand what a specific error message means (and though the debugger works quite well, it's quite  time consuming to set it for debugging if you have a lot of modules). This may seem disrespectful, but I think of the XDS Modula environment as archaic. Other IDEs help in programming by handling the repetitive work for you (with possibilities to do it manually if you please). Also, there is not enough documentation on Modula for it to be interesting to program with (and yes, this wrapper would change a little, and I will publish it; but I don't feel that many new programmers are drawn towards Modula). I have done extensive searching, but most of the documentation is available on about 5 sites; and the rest of the internet (including) is (mostly) quiet about Modula.

Also, I seriously doubt that my work will be more comfortable if I publish the code; first of all there aren't that many libraries available for Modula (and implementing them in another language is something that I just call hacking (as a programmer), but not really a quality product for a language, one of the more practical reasons: the need for a secondary compiler to make it work). And my project is due in a week, after that I don't think I will ever open XDS Modula again (I'm currently using Linux, which does have XDS Modula, but can't be used for the project (as it has to run on Windows, for one), but after this academic year, my VMWare will have to go. I also don't need Modula on daily basis, because there are other programming languages which serve me in programming.

To put it in another way: why should people choose for Modula? What does Modula (as I don't really know Oberon that well, but as far as I know it, it is more object oriented than modula, which is one of the 'new' technologies that is often used today, but isn't included in Modula-2 on a comfortable way: a module is an object, but as far as I know there is no way to make different instances of these objects).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×