QPx_CompressPicture(pictVar; pictVar; pictVar; pictVar; pictVar):error
pictVar Picture Picture variable
codecType Text Codec type
compQuality Longint Compression quality
compDepth Longint Compression depth, optional
compFlags Longint Compression flags, optional
error Longint Error result

Compress a picture variable

This command returns 4D pictures in the new, post v11, picture format. The command essentially is a shortcut for QPx_ExportPictureToBLOB followed by 4D's BLOB TO PICTURE.

The pictVar parameter initially contains the uncompressed picture. When the command completes, it will contain the compressed picture.

The codecType parameter specifies the codec (compressor component) that will do the compression. Use either a codec identifier, as returned by QPx_GetCodecList, or a file format identifier, as returned by QPx_GetExportTypes.

NOTE Codec types are internally mapped to file file format identifiers, as used in commands like QPx_ExportPicture for backwards compatibility.

The compQuality parameter specifies the quality of the compressed picture. Valid values are in the range of 0...1024. QPix defines the following constants for the compQuality parameter:

qpx_MinQuality 0 Minimal quality
qpx_LowQuality 256 Low quality
qpx_NormalQuality 512 Normal quality
qpx_HighQuality 768 High quality
qpx_MaxQuality 1023 Maximum quality
qpx_LosslessQuality 1024 Lossless quality

The compDepth parameter specifies color depth for the compressed image. If omitted or set to 0, QPix uses the original picture depth. Possible values for compDepth are:

qpx_BlackAndWhite 1 Black and white
qpx_FourColors 2 Four colors
qpx_SixteenColors 4 Sixteen colors
qpx_TwoHundredFiftySixColors 8 256 colors
qpx_ThousandsColors 16 Thousands of colors
qpx_MillionColors 24 Million of colors
qpx_MillionColorsPlusAlpha 32 Million of colors plus alpha
qpx_FourGrays 34 Four grays
qpx_SixteenGrays 36 Sixteen grays
qpx_TwoHundredFiftySixGrays 40 256 grays

The optional compFlags parameter specifies additional options. Currently, the only supported option is to display a progress dialog after a short while. To display the progress dialog, set compFlags to 1.

NOTE Not all codecs support all quality and depth values. If a codec does not support the specified values for quality or depth, it will automatically fall back to its respective default values.

NOTE To decompress a picture, compress it with the "raw " (mind the space at the end!) codec, or using QPx_RotatePicture($pict;0) or QPx_ResizePicture($pict;1;1)


   // Compress a picture with the "jpeg" codec



$error:=QPx_CompressPicture ($picture;"jpeg";qpx_NormalQuality)

If ($error=qpx_noErr)
End if 

Related commands

QPx_DoCodecSettingsDialog Display the standard compression settings dialog
QPx_GetCodecList Get the list of available codecs
QPx_GetCompressedPictureInfo Get information about a compressed picture (legacy or new)