VintaSoftTwain Control v6.0
VintaSoftTwain Object / TiffEncoder_Compression Property
In This Topic
    TiffEncoder_Compression Property
    In This Topic
    Gets or sets image compression that TIFF encoder must use when acquired image is encoded.
    Property type
    Read-write property
    Visual Basic
    Public Property TiffEncoder_Compression As enumTiffCompression
    Return Type
    The image compression that TIFF encoder must use for saving image.
    This example shows how to save scanned image to a TIFF file.
    Private VSTwain1 As New VintaSoftTwain()
    ''' <summary>
    ''' Scans images asynchronously.
    ''' </summary>
    Private Sub ScanImages()
        ' open the device manager
        If Not VSTwain1.DeviceManager_Open() Then
            Exit Sub
        End If
        ' open the device
        If Not VSTwain1.Device_Open Then
            Exit Sub
        End If
        ' specify that device UI must be shown
        VSTwain1.Device_ShowUI = True
        ' specify that acquired image must be added to an existing TIFF file
        VSTwain1.TiffEncoder_MultiPage = True
        ' subscribe to the device events
        AddHandler VSTwain1.DeviceImageAcquired, AddressOf VSTwain1_ImageAcquired
        AddHandler VSTwain1.DeviceScanCompleted, AddressOf VSTwain1_ScanCompleted
        AddHandler VSTwain1.DeviceScanFailed, AddressOf VSTwain1_ScanFailed
        AddHandler VSTwain1.DeviceScanCanceled, AddressOf VSTwain1_ScanCanceled
        ' acquire images asynchronously
    End Sub
    Private Sub VSTwain1_ImageAcquired()
        ' get index of acquired image
        Dim imageIndex As Integer = VSTwain1.AcquiredImages_Count - 1
        Dim bpp As Integer = VSTwain1.AcquiredImages_GetImageBitDepth(imageIndex)
        If bpp = 1 Then
            VSTwain1.TiffEncoder_Compression = TIFFCOMPRESSION.TIFFCOMPRESSION_Ccitt4     ' CCITT Fax Group 4
        ElseIf bpp = 8 Then
            VSTwain1.TiffEncoder_Compression = TIFFCOMPRESSION.TIFFCOMPRESSION_Packbits   ' Packbits
            VSTwain1.TiffEncoder_Compression = TIFFCOMPRESSION.TIFFCOMPRESSION_Lzw        ' LZW
        End If
        ' save acquired image to TIFF file
        If Not VSTwain1.AcquiredImages_Save(imageIndex, "test.tif") Then
        End If
    End Sub
    Private Sub VSTwain1_ScanCompleted()
        Console.WriteLine("Scan is completed.")
    End Sub
    Private Sub VSTwain1_ScanFailed(errorString As String)
        Console.WriteLine(String.Format("Scan is failed: {0}.", errorString))
    End Sub
    Private Sub VSTwain1_ScanCanceled()
        Console.WriteLine("Scan is canceled.")
    End Sub
    See Also