Picture.ToData

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

Picture.ToData(format As Picture.Formats, jpegQuality As Integer = Picture.QualityDefault) As MemoryBlock

Supported for all project types and targets.

Converts the Picture to a MemoryBlock.

Notes

Of the value formats, BMP, GIF and TIFF and not supported for Console apps.

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 instead of the literal values.

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

Example

This example uses ToData to convert an image in an ImageWell into a MemoryBlock:

Var mb As MemoryBlock
If productImageWell.Image <> Nil Then
// Get the image data
mb = ProductImageWell.Image.ToData(Picture.Formats.JPEG, Picture.QualityHigh)

// convert the memoryblock back into an image
Imagewell2.Image = Picture.FromData(mb)
End If