Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Animated GIF Problem (beim Erstellen) (https://www.delphipraxis.net/110152-animated-gif-problem-beim-erstellen.html)

spiderb 13. Mär 2008 18:18


Animated GIF Problem (beim Erstellen)
 
Hallo erstmal
Ich wollte aus mehreren bitmaps ein animiertes gif erstellen mit hilfe von delphi.
Ich habe mir die Animated GIF files unit von http://www.tolderlund.eu/delphi/ runtergeladen aber da bekomme ich immer folgenen Fehler:

http://i32.tinypic.com/331zxqh.jpg
Delphi-Quellcode:
function GifAnimateAddImage(Source: TGraphic; Transparent: Boolean; DelayMS: Word): Integer;
var
  Ext       : TGIFGraphicControlExtension;
  LoopExt: TGIFAppExtNSLoop;

  begin

  // Add the source image to the animation
  Result := GIF.Add(source); <- Da liegt iwi das Problem!
  // Netscape Loop extension must be the first extension in the first frame!
  if (Result = 0) then
  begin
    LoopExt := TGIFAppExtNSLoop.Create(GIF.Images[Result]);
    LoopExt.Loops := 0; // Number of loops (0 = forever)
    GIF.Images[Result].Extensions.Add(LoopExt);
  end;
  // Add Graphic Control Extension
  Ext := TGIFGraphicControlExtension.Create(GIF.Images[Result]);
  Ext.Delay := DelayMS div 10; // 30; // Animation delay (30 = 300 mS)
//  if (Result > 0) then
  if (Transparent) then
  begin
    Ext.Transparent := True;
    Ext.TransparentColorIndex := TransparentIndex(GIF.Images[Result]);
  end;
  GIF.Images[Result].Extensions.Add(Ext);
end;
Kann mir jemand helfen?
Danke schonmal.

Klaus01 13. Mär 2008 18:38

Re: Animated GIF Problem (beim Erstellen)
 
Guten Abend,

hast Du schon irgendwo "GifAnimateBegin;"
aufgerufen, denn dort wird die Variable GIF erstellt.

Grüße
Klaus

spiderb 13. Mär 2008 19:49

Re: Animated GIF Problem (beim Erstellen)
 
ja sollte eig hiermit aufgerufen werden.
so soll man das laut doku aufrufen.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  FrameIndex: Integer;
  Picture: TPicture;
begin
  Screen.Cursor := crHourGlass;
  try
    GifAnimateBegin;
    {Step through each frame in in-memory list}
    for FrameIndex := Low(BitMapArray) to High(BitMapArray) do
    begin
      // add frame to animated gif
      GifAnimateAddImage(BitMapArray[FrameIndex], False, 1000);
    end;
    // We are using a TPicture but we could have used a TGIFImage instead.
    // By not using TGIFImage directly we do not have to add GIFImage to the uses clause.
    // By using TPicture we only need to add GifAnimate to the uses clause.
    Picture := GifAnimateEndPicture;
    Picture.SaveToFile(ExtractFilePath(ParamStr(0)) + 'sphere.gif'); // save gif
    //ImageMovieFrame.Picture.Assign(Picture); // display gif
    Picture.Free;
  finally
    Screen.Cursor := crDefault;
  end;
end;

Klaus01 13. Mär 2008 20:38

Re: Animated GIF Problem (beim Erstellen)
 
Guten Abend,

so ich habe die Methode etwas anpassen müssen, da
ich nicht wußte wie Dein Array BitMapArray definiert ist.
Ich habe das jetzt mit einer ImageList gelöst, aber Dein Weg
sollte auch gehen.

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  FrameIndex: Integer;
  Picture: TPicture;
begin
  Screen.Cursor := crHourGlass;
  try
    GifAnimateBegin;
    {Step through each frame in in-memory list}
    for FrameIndex := 0 to BitMapArray.Count -1 do
    begin
      // add frame to animated gif
      BitMapArray.GetBitmap(FrameIndex,Image1.Picture.Bitmap);
      GifAnimateAddImage(Image1.Picture.Graphic,false,1000);
    end;
    // We are using a TPicture but we could have used a TGIFImage instead.
    // By not using TGIFImage directly we do not have to add GIFImage to the uses clause.
    // By using TPicture we only need to add GifAnimate to the uses clause.
    Picture := GifAnimateEndPicture;
    Picture.SaveToFile(ExtractFilePath(ParamStr(0)) + 'sphere.gif'); // save gif
    //ImageMovieFrame.Picture.Assign(Picture); // display gif
    Picture.Free;
  finally
    Screen.Cursor := crDefault;
  end;
end;
Dein Fehlerbild kann ich nicht reproduzieren.

Was ich mir noch vorstellen kann ist,
dass Du gifImage nicht vor FTGifAnimate in den uses geschrieben hast.

Oder stelle mal Deine Deklaration von BitMapArray vor.

Grüße
Klaus

spiderb 13. Mär 2008 20:48

Re: Animated GIF Problem (beim Erstellen)
 
lag scheinbar an der Reihnfolge :wall:
hatte keine Ahnung, dass das auschlaggebend ist!
Vielen Dank!


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:42 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz