Picture.Save

From Xojo Documentation

Method

Picture.Save(file as FolderItem, format as Picture.Formats, jpegQuality as Integer = Picture.QualityDefault)

New in 2010r3

Supported for all project types and targets.

Saves the picture in file specified by file, using the file format specified by format. For the list of available formats, see Picture.Formats.

Notes

fa-info-circle-32.png
Only JPEG and PNG are supported in console applications

If the FolderItem exists, then it will be overwritten by the new picture file.

If you are using the JPEG format, then there is an optional parameter for the quality of the JPEG. You specify the quality using the following class constants.

Introduced 2010r5
Constant Value
QualityDefault -1
QualityMaximum 100
QualityHigh 80
QualityMedium 50
QualityLow 25
QualityMinimum 0

Example

The following example saves the contents of an ImageWell to a temporary file on disk and then reads it into a BinaryStream for storage in a database. The property f as FolderItem is a property of the window.

Var imageData As String
Var bs As BinaryStream
Var f As FolderItem
If ImageWell1.Image <> Nil Then
// Get a temporary file to save the image to
If Picture.IsExportFormatSupported(Picture.FormatJPEG) Then
f = SpecialFolder.Temporary.Child("TempImage.jpg")

// Save the image out to the file
ImageWell1.Image.Save(f, Picture.Formats.JPEG)
End If

// Open the file as a BinaryStream and read the data in
bs = BinaryStream.Open(f, False)
If bs <> Nil Then
imageData = bs.Read(bs.Length)
bs.Close
End If

// delete the temporary file if it exists
If f.Exists Then
f.Delete
End If
End If