This sample illustrates how to save images using the "Save As" dialog. In order to keep things simple, this sample allows only raster images to be loaded and images can be saved in only bmp, jpeg, or gif file formats.

When the "Save" button on the form is clicked, the "Save As" dialog is displayed. In the dropdown menu at the bottom of the "Save As" dialog, there is a choice of file formats in which the image can be saved. In this sample program, only BMP, JPG, and GIF format are allowed. This is done by setting the FileExt property to the following value:

ImageKit1.File.FileExt = "*;BMP;JPG;GIF;"

IMPORTANT: By default, the "Save As" dialog contains an "All Files" option. This option must be removed from the "Save As" dialog dropdown menu when using the File.SaveFileDlgFileType property to determine which format to save the image. If the "All Files" option is selected the File.SaveFileDlgFileType property will return 0. To remove this option, use the asterik symbol "*" in the FileExt property as shown above .

After the file format has been chosen and the "Save" button clicked in the "Save As" dialog, the File.SaveFileDlgFileType property value is retrieved. A Select-Case block is used to execute the appropriate code needed to save the image in that format.

NOTE: When images are saved as JPEG, the image must be 24 bit color or 8 bit grayscale and the JpegQuality value must be set. When images are saved as GIF, the image must be 8 bit or less.