First place Timage and OpenPictureDialog in your form, and then in the uses add jpeg section. Then in the btnLoadPic click event, enter the code as
procedure TForm1.btnLoadPicClick (sender: TObject);
Begin
If not OpenPictureDialog1.Execute Then Exit; Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName); //If not (Image1.Picture.Graphic is TJPEGImage) Then //raise Exception.Create('File not JPEG image');
End;
If you want only a JPEG image, then uncomment the commented lines. In the object inspector, you can set the Timage Stretch property to True.
source share