Page 1 of 1

gflRotate access violation (Delphi)

Posted: Sat Apr 24, 2004 2:21 pm
by daremon
Hi,

i have ported my (Delphi) pet project Cheez to Gfl SDK 2.01.

Everything works fine (and i use most functions in Gfl SDK) except gflRotate() and gflRotateFine().

I get an access violation when using these two functions. The image gets rotated but it seems there is some kind of memory corruption because my program crashes shortly after the rotate (and i can see in the debugger that after the call to gflRotate some objects are destroyed/invalid).

If i replace the one line containing gflRotate() with ANY other function (gflFlipVertical, gflFlipHorizontal, gflBlur, gflBrightness etc) there is no problem, even under extensive testing.

I have tried both modes of calling the function (with and without a destination surface) but both crash... e.g.

e := gflRotate(gfl_bmp, nil, Angle);
or
e := gflRotate(gfl_bmp, gfl_bmp_dst, Angle);

e returns gfl_no_error (so everything seems normal)

Does anyone have any idea what might be causing this?

Thanks,
Dimitris

Posted: Wed Apr 28, 2004 8:39 pm
by Philippe
Hello,

I use the function in my project and i don't have problem.

Code: Select all

var
  InformationFichier: TGFL_File_Information;
  LoadParam          : TGFL_Load_Params;
  Erreur                 : GFL_Error;
  GFLImage           : PGFL_Bitmap;
begin
  Rotation := Rotation + 90;
  if Rotation > 270 then Rotation := 0;
  gflGetDefaultLoadParams(LoadParam);
  LoadParam.Flags := GFL_LOAD_METADATA;
  Erreur := gflLoadBitmap(NomFichier, GFLImage, LoadParam, InformationFichier);
  GFLRotate(GFLImage, nil, Rotation);
end;
(sorry for my english...)

Re: gflRotate access violation (Delphi)

Posted: Thu Apr 29, 2004 4:19 am
by xnview
daremon wrote:Everything works fine (and i use most functions in Gfl SDK) except gflRotate() and gflRotateFine().
In some case, gflRotate can cause an exception. I'll put soon a new release.
Pierre.

PPGFL_BITMAP

Posted: Fri Apr 30, 2004 9:17 am
by daremon
Great news! Thanks!

Also something else you may want to do:

In libgfl.pas, lines 138-140:
138: PGFL_BITMAP = ^TGFL_BITMAP;
139: PPGFL_BITMAP = PGFL_BITMAP;
140: TGFL_BITMAP = record

PGFL_BITMAP is a pointer used by all functions' src parameter. PPGFL_BITMAP is a pointer to a pointer to a TGFL_BITMAP and is used by all functions' dst parameter. If my assumptions are correct, line 139 should be
139: PPGFL_BITMAP = ^PGFL_BITMAP;
(there is a ^ missing)

As it is right now PGFL_BITMAP and PPGFL_BITMAP are the same thing and Delphi accepts and compiles this:

Code: Select all

var
  gfl_bmp_src, gfl_bmp_dst: PGFL_BITMAP;
begin
  gflRotate(gfl_bmp_src, gfl_bmp_dst, 90);

when the correct syntax should be

Code: Select all

gflRotate(gfl_bmp_src, @gfl_bmp_dst, 90);
With PPGFL_BITMAP = ^PGFL_BITMAP;
Delphi would only accept

Code: Select all

var
  gfl_bmp_src: PGFL_BITMAP;
  gfl_bmp_dst: PPGFL_BITMAP;
begin
  gflRotate(gfl_bmp_src, gfl_bmp_dst, 90);


Dimitris