AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Animated GIF Problem (beim Erstellen)
Thema durchsuchen
Ansicht
Themen-Optionen

Animated GIF Problem (beim Erstellen)

Ein Thema von spiderb · begonnen am 13. Mär 2008 · letzter Beitrag vom 13. Mär 2008
Antwort Antwort
spiderb

Registriert seit: 18. Jul 2007
17 Beiträge
 
#1

Animated GIF Problem (beim Erstellen)

  Alt 13. Mär 2008, 18:18
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.
  Mit Zitat antworten Zitat
Klaus01
Online

Registriert seit: 30. Nov 2005
Ort: München
5.755 Beiträge
 
Delphi 10.4 Sydney
 
#2

Re: Animated GIF Problem (beim Erstellen)

  Alt 13. Mär 2008, 18:38
Guten Abend,

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

Grüße
Klaus
Klaus
  Mit Zitat antworten Zitat
spiderb

Registriert seit: 18. Jul 2007
17 Beiträge
 
#3

Re: Animated GIF Problem (beim Erstellen)

  Alt 13. Mär 2008, 19:49
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;
  Mit Zitat antworten Zitat
Klaus01
Online

Registriert seit: 30. Nov 2005
Ort: München
5.755 Beiträge
 
Delphi 10.4 Sydney
 
#4

Re: Animated GIF Problem (beim Erstellen)

  Alt 13. Mär 2008, 20:38
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
Klaus
  Mit Zitat antworten Zitat
spiderb

Registriert seit: 18. Jul 2007
17 Beiträge
 
#5

Re: Animated GIF Problem (beim Erstellen)

  Alt 13. Mär 2008, 20:48
lag scheinbar an der Reihnfolge
hatte keine Ahnung, dass das auschlaggebend ist!
Vielen Dank!
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:33 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