Delphi interface (+ example) improved

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

Post Reply
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

Delphi interface (+ example) improved

Post by AmigoJack »

Hi,

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
GflSDK.20100309.zip
Delphi interface (+ example) improved, based on v3.11
(25.9 KiB) Downloaded 553 times
Cheers.
User avatar
xnview
Author of XnView
Posts: 43595
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Delphi interface (+ example) improved

Post by xnview »

Thank you very much!!
Pierre.
User avatar
madiazg
Posts: 82
Joined: Wed Jul 18, 2007 8:00 pm
Location: Tenerife - Islas Canarias
Contact:

Re: Delphi interface (+ example) improved

Post by madiazg »

Hello,
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;
and

Code: Select all

procedure gflBitmapSetEXIFValueRationalArray2; external GflDLL;
Regards...
Miguel Angel
http://imagen3d.site88.net
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

Re: Delphi interface (+ example) improved

Post 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 :)
User avatar
madiazg
Posts: 82
Joined: Wed Jul 18, 2007 8:00 pm
Location: Tenerife - Islas Canarias
Contact:

Re: Delphi interface (+ example) improved

Post by madiazg »

Hi,
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
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

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

Post 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.
Attachments
GflSDK.20100320.zip
Improved interface and extended example, based on 3.11
(29.6 KiB) Downloaded 357 times
User avatar
madiazg
Posts: 82
Joined: Wed Jul 18, 2007 8:00 pm
Location: Tenerife - Islas Canarias
Contact:

Re: Delphi interface (+ example) improved

Post by madiazg »

Hi,
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.

Regards...
Miguel Angel
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

Re: Delphi interface (+ example) improved

Post 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.
Attachments
GflSDK.20100321.zip
Improved interface and extended example, based on 3.11 with compatibility mode
(31.62 KiB) Downloaded 417 times
User avatar
madiazg
Posts: 82
Joined: Wed Jul 18, 2007 8:00 pm
Location: Tenerife - Islas Canarias
Contact:

Re: Delphi interface (+ example) improved

Post by madiazg »

I use GFL for about 2 years
I am an amateur photographer stereo and I'm developing a program called Imagen3D:
http://imagen3d.site88.net
I'll try this new version and I will indicate to you the results of my tests.

Miguel Angel
nicephore
Posts: 8
Joined: Mon Mar 22, 2010 11:23 am

Re: Delphi interface (+ example) improved

Post by nicephore »

Hi
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
Post Reply