Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:16:12+00:00 2026-06-07T18:16:12+00:00

I have yet another problem regarding GifImage.pas that is included with Delphi XE. The

  • 0

I have yet another problem regarding GifImage.pas that is included with Delphi XE. The issue I have sort of relates to a previous question I asked: TGifImage Transparency Issue

The problem from the previous question above was solved by using the TGifRenderer to display the correct frames from a Gif file which worked perfectly for loading.

But now I need to do the opposite, I need to rebuild and save a new Gif from a series of bitmaps. But when I save, the output Gif file draws incorrectly – just like before.

I am not sure if I need TGIfRenderer again or not because all I am doing is adding bitmaps and packing then saving the Gif.

To see the exact problem I am facing, please carry on reading (apologies in advance for the long post!)

First save these bitmaps to a new sample project folder:

NOTE: These images were originally bitmaps but StackOverflow seems to have converted them to PNG so you might need to copy into Paint and save again.

enter image description here

enter image description here

enter image description here

enter image description here

Now from a new project, paste the following code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, GifImg, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Bmp: TBitmap;
  Gif: TGIFImage;
begin
  Bmp := TBitmap.Create;
  Gif := TGIFImage.Create;
  try
    Bmp.LoadFromFile('img0.bmp');
    Bmp.Transparent := True;
    Gif.Add(Bmp);
    Bmp.LoadFromFile('img1.bmp');
    Bmp.Transparent := True;
    Gif.Add(Bmp);
    Bmp.LoadFromFile('img2.bmp');
    Bmp.Transparent := True;
    Gif.Add(Bmp);
    Bmp.LoadFromFile('img3.bmp');
    Bmp.Transparent := True;
    Gif.Add(Bmp);

    // add netscape loop if we want animation to keep repeating
    TGIFAppExtNSLoop.Create(Gif.Images.Frames[0]).Loops := 0;
    Gif.Pack;
    Gif.SaveToFile('test.gif');
  finally
    Bmp.Free;
    Gif.Free;
  end;
end;

end.

Make sure the saved bitmaps are in the same folder as the project’s exe (or change the filename paths) then run the project to create the output gif.

The saved output is not correct. From the penguin bitmaps saved above, I get this saved Gif:

enter image description here

You can see the frames are overlapping each other or something funky is going on! The source to this gif file can be found from here: http://www.animated-gifs.org.uk/agif/ani02.gif

I did not use all the frames from the Gif as there is so many, but you can see how it should work when animated.

Note that this does not happen with every gif, only a select few seem to save like this. Another example would be to try these bitmaps instead of the penguin:

enter image description here

enter image description here

enter image description here

enter image description here

The result is:

enter image description here

which should be (notice the flames on the plane):

enter image description here

To put it simply, I need to save a Gif from a series of bitmaps to be just like how they were when they were opened. You can see from the sample bitmaps above there is no inconsistency with the actual image data, so this makes me believe it is something to do with how they are added to the gif.

If I do need TGIfRenderer again I am not sure how to implement it for saving, I keep thinking it is for loading only?

This is one of those issues I get that I cannot solve. I’ve been trying to change the transparency and color and mode etc but I cannot seem to figure it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:16:14+00:00Added an answer on June 7, 2026 at 6:16 pm

    I’m not an expert with GIFImg or gif images but the problem seems to be related with disposal of frames. Searching for ‘disposal’ in ‘GIFImg.pas’, I came up with the below which seems to work for your test image:

    ....
    Gif.Add(Bmp); // last frame
    
    for i := 0 to Gif.Images.Count - 1 do
      for j := 0 to Gif.Images[i].Extensions.Count - 1 do
        if Gif.Images[i].Extensions[j] is TGIFGraphicControlExtension then
          TGIFGraphicControlExtension(Gif.Images[i].Extensions[j]).Disposal :=
              dmBackground;
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got yet another deployment problem. What I have: little Windows Forms application that
Yet another in my series of questions regarding constructors in Delphi. i have a
After getting a helpful answer here , I have run into yet another problem:
I have yet another issue which the answer is eluding me. I wish to
I have ran into yet another problem I do not understand. The following does
Yet another question, go me!... Anyway, I have 2 classes with private constructors and
I have another problem that I can't solve I have a following code that
I have yet another problem with extjs. When I build treeview I can't get
So I have yet another problem, I am trying to get an AJAX script
Greetings all, I have yet another RegEx question. I have done hours of searching

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.