First step in GFL SDK and AV error

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

Moderators: helmut, XnTriq, xnview

Post Reply
acsrm
Posts: 3
Joined: Mon Apr 03, 2006 6:21 am
Contact:

First step in GFL SDK and AV error

Post by acsrm »

Hallo. my name is Robert. Sorry for my english.
I want buy your library in light version, now i tested it with my application and i have problem (
My code:

Code: Select all

 
procedure TFDesktop.Button1Click(Sender: TObject); 
  var gfl_bmp: PGFL_BITMAP; 
  lp: TGFL_LOAD_PARAMS; 
  fi: TGFL_FILE_INFORMATION; 
  e: GFL_ERROR; 
begin 
  gflEnableLZW(GFL_TRUE); 
  gflGetDefaultThumbnailParams(lp); 
  lp.Flags := GFL_LOAD_SKIP_ALPHA; 
  lp.Flags := lp.Flags or GFL_LOAD_PREVIEW_NO_CANVAS_RESIZE; 
  e:=gflLoadThumbnail(PAnsiChar('c:\test.jpg',150,150,gfl_bmp,lp,fi); <- this line generate Access Violation error. 
end;
File test.jpg exist. I thing that lp.Flags is mayby not corectly ?

What I done wrong ?
I write in Delphi7.
Please help me.
klaus2

Post by klaus2 »

syntax error; i don't know how it could compile:
closing bracket missing after the filename cast; something like:

e := gflLoadThumbnail(PChar(filename), wid, heigh, gfl_bmp, lp, finfo);
acsrm
Posts: 3
Joined: Mon Apr 03, 2006 6:21 am
Contact:

Post by acsrm »

Hello Klaus2...
Of course I was make a mistake with bracket in example. I write from memory, don't copy from Delphi IDE.
My code compiling without errors.
The problem is still actual.

I have problem with gflBitmapHasEXIF(gfl_bmp) to.
I'm sure that jpeg has EXIF because I read it in other
application i.e. XnView.
In my application gflBitmapHasEXIF always return 0.

For example gflLoadBitmap work correctly.

I work with 2.54 dll.

What's the problem ???

with best regards
Robert
klaus2

Post by klaus2 »

Hello Robert,
don't know, because i don't know your exact code.
The only i can say that the snippet attached works fine
with D4/W9x and D6PE/W2K (i don't have D7).
Maybe your PAnsiChar is the wrong cast.
Best Regards,
klaus2

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var finfo: TGFL_FILE_INFORMATION;
    lp: TGFL_LOAD_PARAMS;
    gfl_bmp: PGFL_BITMAP;
    e: GFL_ERROR;
    filename : String;
begin
  gflEnableLZW(GFL_TRUE);
  gflGetDefaultThumbnailParams(lp);
  lp.ColorModel := GFL_BGR;
  lp.LinePadding := 4;
  lp.Flags := GFL_LOAD_SKIP_ALPHA;
  lp.Flags := lp.Flags or GFL_LOAD_IGNORE_READ_ERROR;
  lp.Flags := lp.Flags or GFL_LOAD_FORCE_COLOR_MODEL;
  filename := GetCurrentDir + '\Image2.jpg';
  e := gflLoadThumbnail(PChar(filename), 40, 40, gfl_bmp, lp, finfo);
end;
 
Guest

Post by Guest »

Hello Klaus2,

I'm shocked. Why ?
Because when I declare:

Code: Select all

var finfo: TGFL_FILE_INFORMATION;
    lp: TGFL_LOAD_PARAMS;
    gfl_bmp: PGFL_BITMAP;
    e: GFL_ERROR;
    filename:string;
is OK
but when I declare (change position in var declaration)

Code: Select all

var gfl_bmp: PGFL_BITMAP; 
      lp: TGFL_LOAD_PARAMS;
      finfo: TGFL_FILE_INFORMATION;
      e: GFL_ERROR;
      filename:string;
in running program I have AV error.

I see that declaration TGFL_LOAD_PARAMS must be after declaration TGFL_FILE_INFORMATION !

Please test this difference in code. Mayby it's a bug in D7 ?

Thank you for your good intentions
Best Regards,
Robert
klaus2

Post by klaus2 »

Hello Robert,

I can confirm with D4/Win98 i get an AV too after having reordered the var defs in the described way,
I can only imagine it's Delphi (although i never encountered such a prob with Delphi); maybe compiler directives?
After testing, with 2.40 this problem did not occur (however here i have to use gflGetDefaultLoadParams instead of gflGetDefaultThumbnailParams);

However, in a similar context, i remember having had an AV when applying a
e := gflGetFileInformation(PChar(filename), -1, finfo);
before the gflLoadThumbnail call (even if i different receiving variable (finfo2) is used).

Somehow strange, indeed, but its possible ot workaround.

klaus2
User avatar
xnview
Author of XnView
Posts: 46236
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Post by xnview »

acsrm wrote:Hello Klaus2...
Of course I was make a mistake with bracket in example. I write from memory, don't copy from Delphi IDE.
My code compiling without errors.
The problem is still actual.

I have problem with gflBitmapHasEXIF(gfl_bmp) to.
I'm sure that jpeg has EXIF because I read it in other
application i.e. XnView.
In my application gflBitmapHasEXIF always return 0.

For example gflLoadBitmap work correctly.

I work with 2.54 dll.

What's the problem ???

with best regards
Robert
Could you send me the jpeg file?
Pierre.
MaierMan
Posts: 78
Joined: Wed Aug 04, 2004 8:32 pm
Contact:

Post by MaierMan »

Never programmed Delphi (at least no serious programming).

I see this declarations in libgfl.pas

Code: Select all

type PGFL_FILE_INFORMATION = ^TGFL_FILE_INFORMATION;
  TGFL_FILE_INFORMATION = record
...

function gflLoadThumbnail(const filename: PChar;
  width, height: GFL_INT32;
  var bitmap: PGFL_BITMAP;
  var params: TGFL_LOAD_PARAMS;
  var info: TGFL_FILE_INFORMATION): GFL_ERROR; stdcall;
while in C it is:

Code: Select all

extern GFLEXTERN GFL_ERROR GFLAPI gflLoadThumbnail( const char *filename, GFL_INT32 width, GFL_INT32 height, GFL_BITMAP **bitmap, const GFL_LOAD_PARAMS *params, GFL_FILE_INFORMATION *info ); 
I'm not quite sure about Delphi stuff, but shouldn't it pass P... types (i.e. the corresponding pointers) to gflLoadThumbnail? (this would surely be true for the other gfl* functions).
At least the C declarations use pointers...
Post Reply