Imam problema sa prikazom trenutnog frejma aktivnog gif-a.
Instalirao sam u Delphi TGifImage, i sad u okviru komponente TImage mogu da ubacim gif fajl. Kako TGifImage dodaje jos gomilu mogucnosti za rad sa samim gif-om, postoji i opcija (parametar, kako vec) prikaza aktivnog frejma, a sintaksa ide
TGifPainter(slika1.Picture.Graphic).ActiveImage : integer;
Ocigledno imam problem da pozovem ovaj parametar, tj. probao sam i sa tajmerom, koji bi na recimo svakih 0.5 sekundi izvrsavao nesto tipa
Label1.Caption := IntToStr(TGifPainter(slika1.Picture.Graphic).ActiveImage);
Label1.Refresh;
Nemam problema sa pokretanjem programa, sve radi osim sto se broj frejmova ne ispisuje, tj. sa ovakvom procedurom (tajmer na 0.5 sec) se u labelu prilikom prvog ontimer dogadjaja upise -1 (sto bi trebalo da je prvi frejm, ne znam zasto ali tako ga prikazuje), i tu i ostane, na -1.
Evo primera iz FAQ fajla, samo da napomenem da nisam uspeo da ga umetnem u svoj kod tako da radi :(
and looking at the demo code) how to get the index of the current
frame in an animated gif. This would be very useful in order make a
text comment in a memo when a certain frame is played thereby
synchronizing text and gif.
Is there a way to get the frame number currectly displayed?
To display the frame number of an animated GIF file:
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenPictureDialog.Execute then
begin
Image.Picture.Assign(nil);
FrameLabel.Caption := '';
Image.Picture.LoadFromFile(OpenPictureDialog.FileName);
if (Image.Picture.Graphic is TGifImage) then
TGifImage(Image.Picture.Graphic).OnPaint := OnGifPaint;
end;
end;
procedure TForm1.OnGifPaint(Sender: TObject);
var
ai: Integer;
begin
ai := (Sender as TGIFPainter).ActiveImage;
FrameLabel.Caption := IntToStr(ai);
FrameLabel.Refresh;
end;
U primeru koji dolazi uz TGifImage (GifExplorer) se lepo ispisuje broj frejmova za sliku za koju ja pokusavam da ispisem to isto na svojoj formi, ali ocito da negde gresim, moze li mi neko pomoci...?
Evo kako izgleda deo koda iz primera Exlporer...
// Update status bar (on animate)
procedure TFormExplorer.OnAnimate(Sender: TObject);
begin
if not(Sender is TGIFPainter) then
exit;
if (TGIFPainter(Sender).ActiveImage < 0) then
begin
StatusBar.Panels[1].Text := '';
end else
begin
StatusBar.Panels[1].Text := ' Frame '+IntToStr(TGIFPainter(Sender).ActiveImage+1) +
' of '+IntToStr(TGIFPainter(Sender).Image.Images.Count);
StatusBar.Update;
end;
end;
Ja sam se potrudio da objasnim svoj problem, ne znam koliko sam u tome uspeo i koliko ste me razumeli, ali ako vam je potrebna jos neka informacija, kod, sta vec, kazite.
Hvala unapred, propadoh uz ovo :(