Open and Save Picture Dialogs

To open an image drop an OpenPictureDialog and a SavePictureDialog onto a form. In the example below this is tied to options in a main menu to Open and Save a file:

The Image control (Additional palette) has been placed on top of a Panel (Standard palette). 

The code running from the File/Open option is:

procedure TForm1.Open1Click(Sender: TObject);
begin
 if openPictureDialog1.execute then
  image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;

The code to save a file is:

procedure TForm1.Save1Click(Sender: TObject);
begin
 if SavePictureDialog1.execute then
  image1.picture.SaveToFile(savepicturedialog1.FileName);
end;

When saving a file you must add the ending to the file name (e.g. .bmp).

Back to Palette List