Page 1 of 1

Delphi interface (+ example) improved

Posted: Tue Mar 09, 2010 7:08 pm
by AmigoJack

I improved the interface for Pascal users to support dynamic linking/loading now. With this the DLLs don't have to be loaded from the start of program execution, which unnecessarily consumes memory. Also you can now point to where the DLLs reside and which filename they have. Full unicode support. Also with checks against loading errors.

Based on SDK version 3.11.

All files changed are included in the attachment. Since all the help files and code comments tell me to send changes to the forum instead of a single person I hereby create this topic. :P
Delphi interface (+ example) improved, based on v3.11
(25.9 KiB) Downloaded 527 times

Re: Delphi interface (+ example) improved

Posted: Wed Mar 10, 2010 9:22 am
by xnview
Thank you very much!!

Re: Delphi interface (+ example) improved

Posted: Fri Mar 12, 2010 10:51 pm
by madiazg
There are some errors in libgfl.pas:

Code: Select all

function gflSetColorAt(src: PGFL_BITMAP; x, y: GFL_INT32; var color: TGFL_COLOR): GFL_ERROR; stdcall;
GFL_EXIF_MAIN_IFD             = $0002;
GFL_EXIF_IFD_0                = $0001;
function gflBitblt(src: PGFL_BITMAP; rect: PGFL_RECT;dst: PGFL_BITMAP; x_dest, y_dest: GFL_INT32): GFL_ERROR; stdcall;
Also be added in EXIF2:

Code: Select all

procedure gflBitmapSetEXIFValueRationalArray2(exif: PGFL_EXIF_DATAEX; ifd, tag: GFL_UINT16; const pq: PGFL_UINT32; count: GFL_INT32); stdcall;

Code: Select all

procedure gflBitmapSetEXIFValueRationalArray2; external GflDLL;
Miguel Angel

Re: Delphi interface (+ example) improved

Posted: Sat Mar 13, 2010 7:57 pm
by AmigoJack
Now that you point to it... the implementation should be

Code: Select all

function gflGetColorAt( const src: PGFL_BITMAP; x, y: GFL_INT32; var color: PGFL_COLOR ): GFL_ERROR; stdcall;
function gflSetColorAt( var dst: PGFL_BITMAP; x, y: GFL_INT32; const color: PGFL_COLOR ): GFL_ERROR; stdcall;
...along with the ...Ex()-functions the same in/out-definitions. But I never worked with them, so I cannot really test it. However, handing over a full color as last parameter instead of a pointer to a color should have been a mistake all along. But I'm gonna investigate if this (my) definition is a more straight translation off the .h.

GFL_EXIF_MAIN_IFD and GFL_EXIF_IFD_0 have been spotted right :)

Also not sure if gflBitblt should not be defined as

Code: Select all

function gflBitblt( src: PGFL_BITMAP; rect: PGFL_RECT; var dst: PGFL_BITMAP; x_dest, y_dest: GFL_INT32 ): GFL_ERROR; stdcall;
...because of dst being altered. But good eye on that parameter anyway :)

Good point in finding out that gflBitmapSetEXIFValueRationalArray2 is also not defined until today. Totally agree with your translation. In the meantime I also found out that gflGetExtraInfos and gflGetExtraInfosCount are not defined, but did that by now (see Thread). When I have all clarifications done I will post a second update. That will also include an improved method for dynamic linking to incorporate the loading of PlugIns also.

So thx along, Miguel :)

Re: Delphi interface (+ example) improved

Posted: Tue Mar 16, 2010 2:48 pm
by madiazg
you're right. The function gflBitmapSetEXIFValueRationalArray2 is not implemented in version 3.11.
Frankly, my level of programming in Delphi is low, as my English level.
I hope this new version of the interface for delphi.
Thanks and regards ...
Miguel Angel

Re: Delphi interface (+ example) improved - 2nd version

Posted: Sat Mar 20, 2010 3:21 pm
by AmigoJack
This second update has completely checked and reviewed the whole interface and the demo example.
  • Reordered all definitions to the same order in the .h-files. This way future additions and corrections can be found much easier.
  • Changed many function parameters to use VAR instead of pointers, where it makes sense.
  • "gflSepiaEx" is now properly linked (was misspelled).
  • Removed "gflBitmapSetEXIFThumbnail" and "gflGetDefaultPreviewParams" as they don't exist at all in current DLLs.
  • Added functions "gflGetExtraInfosCount", "gflGetExtraInfos", "gflBitmapGetEXIFValue" and "gflBitmapSetEXIFValueRationalArray2" (thanks to mediazg for pointing out last one).
  • Added ability to exit, unlink and unload the GFL. This makes sense when you want to re-initialize the whole GFL because of errors or exceptions.
  • Enhanced "gfl_LoadLib" to now also accept a path to plugins. With this, they're also loaded when dynamically linking the GFL. This is also included in the demo now.
  • Enhanced demo to list picture properties along with EXIF data, IPTC data, ICC profile header, Extra infos (TIFF) and trying to list XMP data (see other thread). Also tweaked some code in "FormatInfo_Form" and both window surfaces including controls. The Open-dialog now filters all supported file extensions at once instead of just listing all files initially.
Everything was tested with Delphi 5.62 @ WinXP Pro and Delphi 6.18 (that is Delphi 5 including Update Pack 1) @ WinXP Pro Service Pack 2.

Re: Delphi interface (+ example) improved

Posted: Sat Mar 20, 2010 6:21 pm
by madiazg
Changed many function parameters to use VAR instead of pointers, where it makes sense
This version has many changes from previous version. Such changes require modifying a lot of code in programs and that is a problem.

Miguel Angel

Re: Delphi interface (+ example) improved

Posted: Sat Mar 20, 2010 11:53 pm
by AmigoJack
Hi Miguel,

I know exactly what you mean and somehow expected such a reaction. :wink: So I included another compiler switch {$COMPATIBLE311} which supports nearly all of the old definitions. Not all, because a handful of them were wrong and should not be used anymore. Or I also fixed them and you simply have to change one or two parameters.

If you encounter compiling errors and are not sure on how to solve them, here are two easy rules which have most chances of being encountered:
  • Error: "Types of actual and formal var parameters must be identical"
    Solution: either change @variable to variable or variable to variable^.
  • Error: "Incompatible types: SOMETHING and PSOMETHING"
    Solution: either change variable^ to variable or variable to @variable.
Thanks for testing!
Don't hesitate to name other issues. Or wishes. :)

Oh - one question: how much of GFL do you use, Miguel? My usage so far has not gone beyond what I extended the demo example to: loading a file and getting most of its properties. I'm not into modifying or even drawing on them.

Re: Delphi interface (+ example) improved

Posted: Sat Mar 27, 2010 7:35 pm
by madiazg
I use GFL for about 2 years
I am an amateur photographer stereo and I'm developing a program called Imagen3D:
I'll try this new version and I will indicate to you the results of my tests.

Miguel Angel

Re: Delphi interface (+ example) improved

Posted: Tue Mar 30, 2010 6:00 pm
by nicephore
Whhen i compil the DPR with Delphi7 and opening Nikon D200 NEF file i get error like

FR - "Opération en virgule flottante incorrecte"
EN - "Floating-point operation error"

No pb with Nikon jpeg file format.
I need help for opening Nikon RAW format