OptimizeDir Example for Visual Basic
Dim WithEvents ImageOptmizer As LEADRasterImgOpt
Private Sub ImageOptmizer_OnOptimizeDir()
Static FileCount As Integer
Select Case ImageOptmizer.DirectoryInfo.StatusCode
Case OPTIMIZE_SUCCESS
MsgBox "Operation Successfully Done"
Case OPTIMIZE_DIR_PRE_OPTIMIZING_IMAGE
MsgBox "Operation Successfully Done", , "Note"
Case OPTIMIZE_DIR_OPTIMIZING_IMAGE
With ImageOptmizer.DirectoryInfo
MsgBox Str(.FilePercent) + "% of optimizing " + _
.OriginalFileName + " to " + .OptimizedFileName + Chr(10) _
+ " Files " + Str(FileCount + 1) + " of " + Str(.TotalFolderFilesCount) _
+ " Total Percent " + Str(.TotalPercent) + "% Percent " + Str(.OptimizeOptions.Percent)
If ((.FilePercent = 100) And ((FileCount + 1) <= .TotalFolderFilesCount)) Then
FileCount = FileCount + 1
End If
End With
Case Else
Dim nRet As Integer
With ImageOptmizer.DirectoryInfo
nRet = MsgBox("Error: " + Str(.StatusCode) + " - Optimizing Image!" + Chr(10) + _
.OriginalFileName + Chr(10) + _
"Press OK to skip this file and optimize the next one!", vbOKCancel, "Error")
If (nRet = vbOK) Then
ImageOptmizer.OptimizingError = ERROR_OPT_SKIPIMAGE
Else
ImageOptmizer.OptimizingError = ERROR_OPT_ABORT
End If
End With
End Select
End Sub
Private Sub OptimizeDir_Click()
Dim Options As New LEADOptimizeOptions
Set Options = ImageOptmizer.DefaultOptions
ImageOptmizer.EnableMethodErrors = False
ImageOptmizer.OptimizeDir "c:\Org", "C:\Opt", Options, "*.jpg;*.bmp;*.tmp", True, True
End Sub