QPx_GetCompressedPictureInfo
QPx_GetCompressedPictureInfo(pictVar; pictVar; pictVar; pictVar; pictVar):error | |||
---|---|---|---|
![]() |
pictVar | Picture | Compressed picture |
![]() |
codecType | Text | Codec type |
![]() |
compQuality | Longint | Compression quality |
![]() |
compDepth | Longint | Compression depth |
![]() |
compData | BLOB | The compressed data |
![]() |
error | Longint | Error result |
Get information about a compressed picture (legacy or new)
Parameter pictVar is the picture about which information will be returned. Both the legacy (PICT) and new (post 4Dv11) picture formats are supported.
The remaining parameters receive different things depending on each different case:
Parameter | New picture format | Legacy picture format | ||
---|---|---|---|---|
Supported by QT | Not supported by QT | Compressed by QT | Uncompressed | |
codecType | 4-char code of the QT graphics importer type as reported by QPx_GetImportTypes | Identifier text reported by 4D | 4-char code of the QT codec as reported by QPx_GetCodecList | PICT |
compQuality | QT compression quality | zero | QT compression quality | 1024 (qpx_LosslessQuality) |
compDepth | QT pixel depth | zero | QT pixel depth | image depth |
compData | Image data in codecType format | Raw data in codecType format | Image data in codecType format | empty BLOB |
Parameter compQuality can be used in conjunction with the following constants:
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 |
Parameter compDepth can be used in conjunction with the following constants:
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 |
Example
// ---------------------------------------------------- // Method: PICT_IsLegacyPICT // ---------------------------------------------------- C_PICTURE($1;$pict)// Picture to test C_BOOLEAN($0;$isMacPict)// True if legacy PICT $pict:=$1 $isMacPict:=False C_LONGINT($err;$quality;$depth) C_TEXT($codec) $err:=QPx_GetCompressedPictureInfo ($pict;$codec;$quality;$depth) If ($err=0) // We are using regex for case-sensitive string matching Case of // QT compressed PICTs: codec types are lower-case 4-char codes : (Match regex("^[a-z0-9 ]{4}$";$codec)) $isMacPict:=True // Uncompressed Mac PICT : (Match regex("^PICT$";$codec)) $isMacPict:=True End case End if $0:=$isMacPict // ---------------------------------------------------- // Method: PICT_Upgrade // ---------------------------------------------------- C_POINTER($1;$pictPtr)// Pointer to picture C_TEXT($2;$prefCodec)// Preferred codec for pictures that need to be re-encoded. // Optional, defaults to jpeg. C_LONGINT($3;$prefQuality)// Preferred compression quality for pictures that need to be re-encoded. // Optional, defaults to qpx_NormalQuality. C_LONGINT($0;$result) // 0: no upgrade was necessary // 1: picture converted directly // 2: picture re-encoded // <0: error $pictPtr:=$1 If (Count parameters>1) $prefCodec:=$2 Else $prefCodec:="jpeg" End if If (Count parameters>2) $prefQuality:=$3 Else $prefQuality:=qpx_NormalQuality End if $result:=0 C_PICTURE($pict) $pict:=$pictPtr-> C_LONGINT($err;$quality;$depth) C_TEXT($codec) C_BLOB($data) $result:=QPx_GetCompressedPictureInfo ($pict;$codec;$quality;$depth;$data) If ($result=0) // We are using regex for case-sensitive string matching If (Match regex("^(jpeg|png )$";$codec)) // QT codecs that are converted without re-encoding BLOB TO PICTURE($data;$pict) $pictPtr->:=$pict $result:=1 Else // Other Mac picts - either QT-compressed or uncompressed If (Match regex("^[a-z0-9 ]{4}$";$codec) | Match regex("^PICT$";$codec)) $result:=QPx_CompressPicture ($pict;$prefCodec;$prefQuality) If ($result=0) $pictPtr->:=$pict $result:=2 End if End if End if End if $0:=$result
Related commands
QPx_CompressPicture | Compress a picture variable |
QPx_GetPictureInfo | Get the properties of a 4D picture variable |
QPx_GetImportTypes | Get the list of available importers |
QPx_GetCodecList | Get the list of available codecs |