Board index » delphi » Load JPEG-pictures in a TImage component

Load JPEG-pictures in a TImage component

Hello,

how can I load JPEG-pictures in a TImage component? LoadPicture do not work.

Thanks in advance

Achim Habbel, Germany

 

Re:Load JPEG-pictures in a TImage component


Add JPEG to the uses clause.

procedure TForm1.Button1Click(Sender: TObject);
var
  JPEG: TJPEGImage;
begin
  with OpenPictureDialog1 do
  begin
    Filter := 'JPEG-Bild (*.jpg, *.jpeg)|*.jpg;*.jpeg';
    if Execute then
    begin
      JPEG := TJPEGImage.Create;
      try
        JPEG.LoadFromFile(FileName);
        Image1.Picture.Bitmap.Assign(JPEG);
      finally
        JPEG.Free;
      end;
    end;
  end;
end;

Kerstin

Quote
Achim Habbel wrote:

> Hello,

> how can I load JPEG-pictures in a TImage component? LoadPicture do not work.

> Thanks in advance

> Achim Habbel, Germany

Other Threads