AutoTrim example for Visual Basic

Note: Also works with Access 95 and 97.

This example scans a document and trims the edges.

'Make sure display rectangles are reset when we acquire the image.
Lead1.AutoSetRects = True

'Disable automatic repainting.
Lead1.AutoRepaint = False

'Acquire the image, allowing for possible mistakes.
SavedSetting = Lead1.EnableMethodErrors
Lead1.EnableMethodErrors = False
nRet = Lead1.Load("d:\temp\test.tif", 0, 1, 1)
If nRet <> 0 Then
    MsgBox "image not loaded"
    Lead1.EnableMethodErrors = SavedSetting
    GoTo FINISHED
End If
Lead1.EnableMethodErrors = SavedSetting

'Trim the edges of the acquired bitmap.
Lead1.AutoTrim (64)

'Use the whole window.
Lead1.Top = 0
Lead1.Left = 0
Lead1.Width = ScaleWidth
Lead1.Height = ScaleHeight

'Set up for good display of a typical scanned document.
Lead1.BitonalScaling = BITONALSCALING_SCALETOGRAY
Lead1.AutoScroll = True
Lead1.DstWidth = Lead1.ScaleWidth 'Use the full control width.
Lead1.DstClipWidth = Lead1.ScaleWidth
CalcHeight = (Lead1.BitmapHeight * Lead1.ScaleWidth) / Lead1.BitmapWidth
Lead1.DstHeight = CalcHeight 'Use the proportional height.
Lead1.DstClipHeight = CalcHeight

'Enable automatic repainting.
Lead1.AutoRepaint = True

FINISHED: