Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi GIF in TImage (https://www.delphipraxis.net/69116-gif-timage.html)

qb-tim 10. Mai 2006 14:49

Re: GIF in TImage
 
Ich habe folgendes hinzugefügt:

Delphi-Quellcode:
 Test.Parent := Form1;
 Test.Show;
und folgendes kam dabei raus:

Delphi-Quellcode:
[Fehler] Unit1.pas(31): Undefinierter Bezeichner: 'Parent'
[Fehler] Unit1.pas(32): Undefinierter Bezeichner: 'Show'
:wiejetzt:

Klaus01 10. Mai 2006 15:12

Re: GIF in TImage
 
schau mal ob es so geht, ansosten stelle ich heute Abend noch was ein,
habe noch ein Beispiel zuhause.

Delphi-Quellcode:
begin
  gif := TGIFImage.Create;
  gif.LoadFromFile('c:\giftest.gif');
  gif.Paint(Canvas,Form1.ClientRect,[goDirectDraw]);
end;



begin
  gif.Free;
end;
HowTo aus der FAQ:
Zitat:

How do you use the GifImage unit?


Simply add the GifImage unit to one the uses clauses in your program.
Then you can load GIF files into a TImage component the same way you load BMP files.

uses
GifImage;

procedure TForm1.Button1Click(Sender: TObject);
begin
Image.Picture.LoadFromFile('C:\SomeDir\SomeFile.gi f');
end;

-----

How to display animated GIF picture on the form?


Put GifImage in your uses clause in the program.
Then you can use Delphi's TImage component to load animated gif pictures.

-----
Die FAQ -> http://finn.mobilixnet.dk/delphi/gif-faq.txt

Grüße
Klaus

himitsu 10. Mai 2006 18:41

Re: GIF in TImage
 
Zitat:

Zitat von Matze
Bei der Unit JPEG ist das so, aber TGifImage ist doch eine externe Unit, die nicht mit Delphi geliefert wird. :gruebel:

:wall: dann halt nicht ... ignoriert mich also einfach ._.

SirThornberry 10. Mai 2006 18:51

Re: GIF in TImage
 
Dieses TGifImage ist wie TBitmap und TJPEGImage ein nachfahre der Klasse TGraphic. Somit gibt es da kein Show, Parent etc. Allerdings sollte es möglich sein die Graphiken mit Assign untereinander zu zuweisen bzw. einem TImage zu zuweisen.

folgendes sollte auf jeden fall funktionieren:
Delphi-Quellcode:
var LGif: TGifImage;
begin
  LGif := TGifImage.Create;
  LGif.LoadFromFile('YourGifFile.Gif');
  Image1.Picture.Graphic := LGif;
  LGif.Free;

qb-tim 11. Mai 2006 13:51

Re: GIF in TImage
 
Hhmm...

Delphi-Quellcode:
//in Unit1 - Form1 ist schon erstelt worden
var
  Form1: TForm1;
  Test: TGIFImage;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
 Form1.Height := 231;
 Form1.Width := 165;
 Test := TGifImage.Create;
 Test.Height := 231;
 Test.Width := 165;
 Test.LoadFromFile('C:\gif\pic001.gif');
 Test.Paint(Canvas,Form1.ClientRect,[goDirectDraw]);
end;
Dann kommt die Fehlermeldung: "Im Projeck Project1.exe ist eine Exception der Klasse EOSError aufgetreten. Meldung: 'Systemfehler. Code: 6. The handle is invalid'. Prozeß wurde angehalten. Mit Einzelne Anweisung oder Start fortsetzen." und der folgende Text wird blau markiert:

Delphi-Quellcode:
// Line: 12440
Result := nil;
Dieser Befehl befand sich in der GifUnit:

Delphi-Quellcode:
// Internal pain(t) routine used by Draw()
function TGIFImage.InternalPaint(Painter: PGifPainter; ACanvas: TCanvas;
  const Rect: TRect; Options: TGIFDrawOptions): TGIFPainter;
begin
  if (Empty) or (Rect.Left >= Rect.Right) or (Rect.Top >= Rect.Bottom) then
  begin
    Result := nil;
    if (Painter <> nil) then
      Painter^ := Result;
    exit;
  end;

  // Draw in main thread if only one image
  if (Images.Count = 1) then
    Options := Options - [goAsync, goAnimate];

  Result := TGIFPainter.CreateRef(Painter, self, ACanvas, Rect, Options);
  FPainters.Add(Result);
  Result.OnStartPaint := FOnStartPaint;
  Result.OnPaint := FOnPaint;
  Result.OnAfterPaint := FOnAfterPaint;
  Result.OnLoop := FOnLoop;
  Result.OnEndPaint := FOnEndPaint;

  if not(goAsync in Options) then
  begin
    // Run in main thread
    Result.Execute;
    // Note: Painter threads executing in the main thread are freed upon exit
    // from the Execute method, so no need to do it here.
{hier kommt der Fehler!}
    Result := nil;
    if (Painter <> nil) then
      Painter^ := Result;
  end else
    Result.Priority := FThreadPriority;
end;
Was habe ich (oder ist) falsch?

PS: Ich habe die GifUnit von hier: http://www.torry.net/vcl/graphics/gif/gifimaged7c.zip

qb-tim 11. Mai 2006 13:56

Re: GIF in TImage
 
Auch wenn ich folgendes schreibe passiert das gleiche... :?

Delphi-Quellcode:
//Form1 ist schon erstellt worden
//Image1 ist schon erstellt worden und hat die richtige Größe schon

var
  Form1: TForm1;
  Test: TGIFImage;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
 Form1.Height := 231;
 Form1.Width := 165;
 Test := TGifImage.Create;
 Test.Height := 231;
 Test.Width := 165;
 Test.LoadFromFile('C:\gif\pic001.gif');
 Test.Paint(Canvas,Form1.ClientRect,[goDirectDraw]);
 Image1.Picture.Graphic := Test;
 Test.Free;
end;
:wiejetzt:

Klaus01 11. Mai 2006 15:01

Re: GIF in TImage
 
Delphi-Quellcode:
uses
  ..TGifImage;
...
var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
  Form1.Height := 231;
  Form1.Width := 165;
  Image1.Picture.loadFromFile('c:\test.gif');
schau mal bitte in die FAQ die ich hier in einem vorherigen Beitrag angehängt habe
da ist all das erklärt.

Grüße

Klaus

SirThornberry 11. Mai 2006 15:03

Re: GIF in TImage
 
Welchen Sinn hat es das du von dem GifImage die Größe mit "Test.Width" setzt wenn du anschließend LoadFromFile aufrufst? Durch das LoadFromFile wird das aktuell geladene Image entfernt und das aus der Datei geladen mit den entsprechenden Größen der Datei.

Hast du es eigentlich schon so versucht wie ich es gestern gepostet hab? Ich hab das Gefühl du hast das einfach ignoriert.

Warum rufst du eigentlich "Test.Paint" auf? Ich dachte du willst das Bild in deinem TImage anzeigen.

qb-tim 11. Mai 2006 15:31

Re: GIF in TImage
 
:oops:

Ich hab das :oops: übersehen :pale:

So löse ich das Problem:

Delphi-Quellcode:
uses {...} GifImage

procedure TForm1.FormActivate(Sender: TObject);
begin
 Image1.Picture.LoadFromFile('C:\irgernd_ein_gif.gif');
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:03 Uhr.
Seite 2 von 2     12   

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