// Getestet mit D4 unter XP

// Downloaden von 
// https://github.com/mike-lischke/GraphicEx 
 
// Unterstützte Extensionen: 
// bmp bw cel cut dib emf eps fax icb ico jfif jpe jpeg jpg pbm pcc 
// pcd pcx pdd pgm pic png ppm psd psp rgb rgba rla rle rpf scr sgi 
// tga tif tiff vda vst win wmf 
 
// Beispiel 
 
unit Unit1; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
  ExtCtrls, ExtDlgs, StdCtrls; 
 
type 
  TForm1 = class(TForm) 
    Image1: TImage; 
    Button1: TButton; 
    OpenPictureDialog1: TOpenPictureDialog; 
    procedure Button1Click(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
  private 
    { Private-Deklarationen } 
  public 
    procedure Laden(const FileName: TFileName; Pic: TPicture); 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
{$R *.DFM} 
 
uses GraphicEx; 
 
procedure TForm1.Laden(const FileName: TFileName; Pic: TPicture); 
var 
  ExClass: TGraphicExGraphicClass; 
  Grphc: TGraphic; 
begin 
  Screen.Cursor := crHourGlass; 
  try 
    ExClass := FileFormatList.GraphicFromContent(FileName); 
    if ExClass = nil then 
      Pic.LoadFromFile(FileName) 
    else begin 
      Grphc := ExClass.Create; 
      Grphc.LoadFromFile(FileName); 
      Pic.Graphic := Grphc; 
      Grphc.free; 
    end; 
    Screen.Cursor := crDefault; 
  except 
    Screen.Cursor := crDefault; 
    showmessage('Datei konnte nicht geladen werden'); 
  end; 
end; 
 
procedure TForm1.FormCreate(Sender: TObject); 
var 
  Extensions: TStringlist; 
  i: Integer; 
  s: string; 
begin 
  Extensions := TStringList.Create; 
  Extensions.sorted := true; 
  FileFormatList.GetExtensionList(Extensions); 
  s := 'Alle unterstützten Dateien|'; 
  for i := 0 to Extensions.count - 1 do 
    s := s + '*.' + Extensions[i] + ';'; 
  for i := 0 to Extensions.count - 1 do begin 
    s := s + '|' + AnsiUppercase(Extensions[i]) + '|' + '*.' + Extensions[i]; 
  end; 
  OpenPictureDialog1.Filter := s; 
  Extensions.free; 
end; 
 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  OpenPictureDialog1.FilterIndex := 0; 
  OpenPictureDialog1.Filename := ''; 
  if OpenPictureDialog1.Execute 
    then Laden(OpenPictureDialog1.FileName, Image1.Picture); 
end; 
 
end.



 

Zugriffe seit 6.9.2001 auf Delphi-Ecke