0

While a process is running in the background, I show a loading animation on the screen. But the GIF looks very bad quality. How can I fix this problem?

unit Unit3;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.GIFImg, Vcl.ExtCtrls,
  Vcl.StdCtrls;

type
  TForm3 = class(TForm)
    Image1: TImage;
    procedure FormShow(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  var
    sFile: string;
  end;

var
  Form3: TForm3;
  aGIF: TGIFImage;
  bmp:TBitmap;

implementation

{$R *.dfm}

procedure TForm3.FormShow(Sender: TObject);

begin
  aGIF := TGIFImage.Create;
  aGIF.LoadFromFile(sFile);
  aGIF.Animate := True;
  Image1.Picture.Assign(aGIF);
  aGIF.Free;
end;

end.

image

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
ryana42
  • 11
  • 1
  • Can't you use the `TActivityIndicator`? – Andreas Rejbrand Mar 30 '21 at 14:24
  • Unfortunately, I want use loading GIF animate. – ryana42 Mar 30 '21 at 14:46
  • Are you using any VCL Style? The form looks darker than standard (like there would be an overlay) and the form header is not the standard color. Is the GIF available for download for testing? – Tom Brunberg Mar 30 '21 at 15:19
  • Did you check whether the gif itself is of a good quality...? – R. Hoek Mar 30 '21 at 15:39
  • Did you try with another GIF? What if you run the same GIF in another (not Delphi) program? – fpiette Mar 30 '21 at 15:43
  • Based on the image provided it seems that this is a low resolution GIF stretched to much larger size. Since GIF's are raster based images stretching them will cause them to look pix-elated. You should find suitable larger GIF to use instead of this one. That way your image wont be garbled due to stretching to much larger size than original is. – SilverWarior Mar 30 '21 at 22:32
  • In fact, three forms are shown. The main form shown first. The second form shown is transparent and has a black background. The third shown form contains GIF. It has a transparent background in the third form. The GIFs I use are normally good quality and large enough in size. I think the problem is that the background of the form in which the GIF is located is transparent. – ryana42 Mar 31 '21 at 06:10
  • Why three forms? Are you using the second form to make your main form appear darker while GIF animation is being played? – SilverWarior Mar 31 '21 at 11:06
  • Yes, I use second form for appear darker. – ryana42 Apr 02 '21 at 06:04

0 Answers0