Picture.GetData

From Xojo Documentation

Method

Picture.GetData(format As String, quality As Integer = QualityDefault) As MemoryBlock

Supported for all project types and targets.

Converts the Picture to a MemoryBlock.

Notes

Valid formats are:

  • Picture.FormatBMP (not supported in Console apps)
  • Picture.FormatGIF (not supported in Console apps)
  • Picture.FormatJPEG
  • Picture.FormatPNG
  • Picture.FormatTIFF (not supported in 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.

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

Example

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

Dim mb As MemoryBlock
If productImageWell.Image <> Nil Then
// Get the image data
mb = ProductImageWell.Image.GetData(Picture.FormatJPEG, Picture.QualityHigh)

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