AviCompressor.CompressorDataSize Property

Returns the size of the SAFEARRAY of Byte returned by CompressorData.
Syntax:
Public CompressorDataSize As Long
Limitations:

Read only.

Remarks:

The CompressorDataSize is useful, if codec properties are to be saved to a file. Reading the size value first from file, enables an application to create an array of the matching size that will get the codec properties.

Sample:

How to use the CompressorDataSize is shown in the sample Saving Codec Properties.

' Global declaration of the AviCompressr object
Dim Codec As AviCompressor

Save the data from a codec that was selected in a combo box.

Private Sub cmdSaveData_Click()
    Dim Data() As Byte ' Dynamic array for the data stream.
 
    Open "test.bin" For Binary As #1 ' Must be opened binary!
 
    ' Save the length of the codec's name.
    Put #1, , Len(Codec.Name)
 
    ' Save the name of the codec.
    Put #1, , Codec.Name
 
    ' Save the byte count of the data stream. It is used
    ' when data is loaded from file to resize the dynamic array.
    Put #1, , Codec.CompressorDataSize
    
    ' Get the data from the codec.
    Data = Codec.CompressorData
 
    ' Save the data to the file.
    Put #1, , Data
    Close #1
End Sub

Load the previously saved data and assign it to a codec.

Private Sub cmdLoadData_Click()
    Dim Data() As Byte      ' Dynamic array for the data stream.
    Dim Length As Long      ' Length of the data stream.
    Dim NameLength As Long  ' Length of the codec's name.
    Dim CodecName As String ' Name of the codec.
    Dim i As Integer
 
    Open "test.bin" For Binary As #1 ' Must be opened binary!
 
    ' Read the length of the codec's name.
    Get #1, , NameLength
 
    ' Allocate memory for the name.
    CodecName = String(NameLength, " ")
 
    ' Read the name of the codec.
    Get #1, , CodecName
 
    ' Compare the names.
    If CodecName = Codec.Name Then
        ' Read the length of the follwing data.
        Get #1, , Length
 
        ' Resize the data array to Length.
        ReDim Data(Length)
 
        ' Read the codec data from the file.
        Get #1, , Data
 
        ' Assign the read data to the codec object.
        Codec.CompressorData = Data
    Else
        MsgBox "The saved data does not match to the used codec." + Chr(13) + _
               "saved: " + CodecName + Chr(13) + _
               "used: " + Codec.Name
    End If
    Close #1
End Sub
See Also: AviCompressor, AviCompressor.CompressorData

<< AviCompressor

This site is part of The Imaging Source Network. Other sites include Company Portal, Image Processing, Astronomy Cameras, Astronomy Cameras Blog, Blog caméras d'astronomie, Astronomy Cameras Competition, TX Text Control, TX Text Control Blog and Forums.