Known Problems and Bugs 

The following are the problems with TGIFImage that are known to exist at this time (10-may-1999).
Please check out the bug list at the TGIFImage home page for up to date information.

In the following code snippets, red text denotes text that should be added or modified and red, strike-through text denotes text that should be deleted.

C++ Builder 4 problems
bug Compiling gifimage.pas with C++ Builder 4 fails with the following error: Unsupported language feature:'property of array type'.
To avoid this error, the TGIFApplicationExtension.Identifier and Authentication properties must be disabled by removing the following lines in the declaration of the TGIFApplicationExtension class in gifimage.pas:

TGIFApplicationExtension = class(TGIFExtension)
private
  FIdent : TGIFApplicationRec;
protected
  function GetExtensionType: TGIFExtensionType; override;
  procedure SaveData(Stream: TStream); virtual; abstract;
  procedure LoadData(Stream: TStream); virtual; abstract;
public
  constructor Create(ASubImage: TGIFSubImage); override;
  destructor Destroy; override;
  procedure SaveToStream(Stream: TStream); override;
  procedure LoadFromStream(Stream: TStream); override;
  class procedure RegisterExtension(eIdent: TGIFApplicationRec; eClass: TGIFAppExtensionClass);
  class function FindSubExtension(Stream: TStream): TGIFExtensionClass; override;
  property Identifier: TGIFIdentifierCode read FIdent.Identifier
    write FIdent.Identifier;
  property Authentication: TGIFAuthenticationCode read FIdent.Authentication
    write FIdent.Authentication;
end;


bug The following modification is needed for some of the following bug fixes. At the start of the gifimage unit, add the following;
// C++ Builder 4.x
{$IFDEF VER125}
{$DEFINE VER10_PLUS}
{$DEFINE VER11_PLUS}
{$DEFINE VER12_PLUS}
{$DEFINE VER125_PLUS}
{$ENDIF}


bug When compiling the TGIFImage demo applications, you will get the following errors:
Unable to find package import for inetdb40.bpi and inet40.bpi
Unable to open file DCLUSR40.LIB
This is caused by a bug in C++ Builder's conversion of the projects from C++ Builder version 3 to version 4 format. To resolve the problem, do the following for all the demo .BPR files (make files):
1 Exit C++ Builder (to avoid caching problems).
2 Open the .BPR file in notepad.
3 In the SPARELIBS line, remove the reference to DCLUSR40.lib.
4 In the PACKAGES line, remove the references to inetdb40.bpi and inet40.bpi
5 Save the file.

bug Because the return value of most GDI functions has changed from Integer (signed) to Cardinal (unsigned), the GDICheck function can cause a "Range Check" exception in some cases.
To avoid this change the following lines in the implementation of the GDICheck function in gifimage.pas:

{$ifdef VER110}
function GDICheck(Value: Integer): Integer;
{$else}
function GDICheck(Value: Cardinal): Cardinal;
{$endif}


bug The AVI2GIF demo application has a bug that causes it to fail with an "Integer Overflow" error.
The bug can be fixed by deleting the following line of the TFormMain.ButtonConvertClick method in main.pas of the AVI2GIF demo application:

// Copy palette to DIB
for i := 0 to BitmapInfo^.bmiHeader.biClrUsed-1 do
  Move(BitmapInfo^.bmiColors, Bits^.bmiColors,
    (BitmapInfo^.bmiHeader.biClrUsed * sizeof(TRGBQuad)));


bug C++ Builder's Pascal compiler has a bug that causes the compiler to pack auto variables when optimization is enabled. This causes problems for certain GDI functions which requires alligned data.
The bug can be worked around by disabling optimization locally for the methods which requires stack aligment. Apply the following two modifications to gifimage.pas:

{$IFDEF D4_BCB3}
{$IFDEF VER11_PLUS}
  // Disable optimization to circumvent D4/BCB3/BCB4 optimizer bug
  {$IFOPT O+}
    {$DEFINE O_PLUS}
    {$O-}
  {$ENDIF}
{$ENDIF}
procedure InitializeBitmapInfoHeader(Bitmap: HBITMAP; var Info: TBitmapInfoHeader;
  PixelFormat: TPixelFormat);

and

{$IFDEF D4_BCB3}
{$IFDEF VER11_PLUS}
  // Disable optimization to circumvent D4/BCB3/BCB4 optimizer bug
  {$IFOPT O+}
    {$DEFINE O_PLUS}
    {$O-}
  {$ENDIF}
{$ENDIF}
function GetPixelFormat(Bitmap: TBitmap): TPixelFormat;


General problems
bug In some rare cases, the frames of an animated GIFs are alternately displayed too fast and too slow.
The problem is that the GIF renderer attempts to adjust the interframe delay to compensate for the time spent converting the GIF to bitmaps and drawing the frames. In some cases the present algorithm alternately over- and undercompensates and thus causes a feedback oscillation.
To fix the problem, modify the following line of TGIFPainter.Execute in gifimage.pas:

// Calculate number of mS used in prefetch and display
try
  DelayUsed := ((NewDelayStart-DelayStart)-OldDelay) DIV 2;
  OldDelay := Delay * GIFDelayExp;
  // Convert delay value to mS and...
  // ...Adjust for time already spent converting GIF to bitmap and...
  // ...Adjust for Animation Speed factor.
  Delay := MulDiv(Delay * GIFDelayExp - DelayUsed, 100, FAnimationSpeed);
except
  Delay := GIFMaximumDelay * GIFDelayExp;
end;


bug Displaying a non-animated GIF with the TGIFImage.Paint nethod causes the application to hang or crash with an access violation.
Apply the following modifications to TGIFImage.InternalPaint in gifimage.pas:

// Note: Painter threads executing in the main thread are freed upon exit
// from the Execute method, so no need to do it here.
Result := nil;
if (Painter <> nil) then
  Painter^ := Result;

and:

// Draw in main thread if only one image
if (Images.Count = 1) then
  Options := Options - [goAsync, goAnimate];


Old problems
bug The combination of buffered, tiled and transparent draw will display the background incorrectly (scaled).
Consider using the goDirectDraw option to circumvent this problem.

bug The combination of non-buffered (goDirectDraw) and stretched draw is some times distorted with a checkerboard effect.
The cause of this problem is believed to be a bug in either Windows GDI or certain video drivers.

bug Buffered display flickers when TGIFImage is used by a transparent TImage component to display an animated GIF.
This is a problem with TImage caused by the fact that TImage was designed with static images in mind. Not much I can do about it.

bug The VCL unit graphics.pas in Delphi 3.0 contains a bug that causes multi-threaded applications to hang if they use TBitmap. If you plan to use the multi-threaded GIF painter or use TGIFImage in multi-threaded applications (Delphi 3 CGI applications are multi-threaded) you'll have to fix the bug in graphics.pas.
The modification you need to perform on graphics.pas are described here but are also available from The Delphi Bug List.
The bug has been fixed by Borland in Delphi 3.01.

bug The ByteSwapColors procedure of the Delphi 3.0 graphics.pas unit contains a bug that affects TGIFImage.
ByteSwapColors is used various places in graphics.pas to convert an array of RGB values (TPaletteEntry) to BGR values (TRGBQuad) and vice versa. The problem is that the first entry of the array is never converted.
The problem does not exist in versions of Delphi prior to 3.0 since they use a different method to convert between RGB and BGR.
The modification you need to perform on graphics.pas are described here.
The bug has been fixed by Borland in Delphi 3.01.


 


Copyright © 1998-99 Anders Melander. All rights reserved.