gflRotate access violation (Delphi)

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

Moderators: helmut, XnTriq, xnview

Post Reply
daremon

gflRotate access violation (Delphi)

Post 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
Philippe
Posts: 3
Joined: Wed Apr 28, 2004 11:27 am
Location: Ch'ti (France)
Contact:

Post 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...)
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: gflRotate access violation (Delphi)

Post 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.
daremon

PPGFL_BITMAP

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