Einzelnen Beitrag anzeigen

Markus
(Gast)

n/a Beiträge
 
#1

Thumbnail eines JPEGs in einem TBitmap speichern...

  Alt 27. Aug 2004, 12:35
Hallo,

ich erstelle mit folgender Funktion Thumbnails von Jpegs:

Delphi-Quellcode:
    procedure createthumb(thumb: TBitmap; datei: string; hoehe, breite: integer);
    var tjpg: TJpegImage;
        tx,ty,tb,th: integer;
    begin
        tjpg:=TJpegImage.Create;
        try
          tjpg.LoadFromFile(datei);
        finally

        tb:=round(tjpg.Width/breite);
        th:=round(tjpg.Height/hoehe);

        if tjpg.Width>tjpg.Height then begin
          tx:=0;
          ty:=hoehe-(round(breite/th) div 2);
        end
        else begin
          tx:=breite-(round(hoehe/tb) div 2);
          ty:=0;
        end;

        thumb.PixelFormat := pf24Bit;
        thumb.Width:=breite;
        thumb.Height:=hoehe;
        thumb.Canvas.Rectangle(0,0,breite,hoehe);
        thumb.canvas.StretchDraw(Rect(tx,hoehe-ty,breite-tx,ty),tjpg);

      end;
      tjpg.Free;
    end;
Leider ist diese Funktion unendlich langsam. Weiß jemand wie man das beschleunigen kann? das TBitmap thumb wird schon erstellt übergeben (daher kein create).
  Mit Zitat antworten Zitat