I wrote the following code to go to the specified INPUT folder, search for all
.TIF files, load them 1 by 1, save them to the specified OUTPUT folder as BITMAP
(.BMP) images.
------------------------------
Const INPUT_EXTENSION As String = ".tif"
Const INPUT_PATH As String = "C:\"
Const OUTPUT_EXTENSION As String = ".bmp"
Const OUTPUT_PATH As String = "C:\!TEMP5\"
Dim objAIL As New cAdvancedImagery
Dim hIMG As Long
Dim arrFiles() As String
Dim lngTotal As Long
Dim lngCounter As Long
Dim strPath As String
strPath = Dir(INPUT_PATH & "*" & INPUT_EXTENSION, vbArchive Or vbHidden Or
vbNormal Or vbReadOnly Or vbSystem)
If strPath = "" Then
MsgBox "No image files found", vbOKOnly Or vbInformation, " "
Exit Sub
End If
Do While strPath <> ""
If strPath <> "." And strPath <> ".." Then
ReDim Preserve arrFiles(0 To lngTotal) As String
arrFiles(lngTotal) = strPath
lngTotal = lngTotal + 1
End If
strPath = Dir()
Loop
Set objAIL = New AdvImgLib.cAdvancedImagery
For lngCounter = 0 To (lngTotal - 1)
If objAIL.IO_LoadImage(INPUT_PATH & arrFiles(lngCounter), hIMG) = True Then
strPath = OUTPUT_PATH & Replace(arrFiles(lngCounter), INPUT_EXTENSION,
OUTPUT_EXTENSION, , , vbTextCompare)
If objAIL.IO_SaveImage(hIMG, strPath, IF_BMP, BMP_DEFAULT, True) = True
Then
Debug.Print "Successfully saved image: " & strPath
Else
MsgBox "Error saving image '" & strPath & "': " & objAIL.Error_GetLast
End If
Call objAIL.IO_DestroyImage(hIMG)
Else
MsgBox "Error loading image - " & objAIL.Error_GetLast
End If
Next
Set objAIL = Nothing