IC Imaging Control ActiveX

AviCompressor.CompressorDataSize Property

AviCompressor.CompressorDataSize Property

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

Read only.


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.


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
        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

Get in touch with us

About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, frame grabbers and video converters for production automation, quality assurance, logistics, medicine, science and security.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

Automated Imaging Association ISO 9001:2015 certified

Contact us