Available in the LEADTOOLS Imaging toolkit. |
LoadInfo... example for Visual Basic
Take the following steps to exercise the LoadInfo event and LoadInfo... properties. The example creates a raw FAX file, then loads the file it just created. (Getting format information from an unfamiliar file is beyond the scope of this example.)
1. Start with the project that you created in Loading and Displaying an Image.
2. Add the following form-level variables to the declarations procedure of the general object in your main form:
'Declare variables for demonstrating raw FAX.
Dim MyInfoBits As Integer
Dim MyInfoFlags As Long
Dim MyInfoFormat As Integer
Dim MyInfoHeight As Single
Dim MyInfoOffset As Long
Dim MyInfoWidth As Single
Dim MyInfoXRes As Integer
Dim MyInfoYRes As Integer
3. Add a CommandButton control and code its click procedure as follows:
Private Sub Command4_Click()
Lead1.ScaleMode = 3 'Pixels
'Make the image look OK as a 1-bit image.
Lead1.Size Lead1.ScaleWidth, Lead1.ScaleHeight, RESIZE_RESAMPLE
Lead1.Halftone HALFTONE_VIEW, 45
'Set the form-level variables to the values we will use when loading.
MyInfoBits = 1
MyInfoFlags = LOADINFO_TOPLEFT
MyInfoFormat = FILE_FAX_G3_2D
MyInfoHeight = Lead1.BitmapHeight
MyInfoOffset = 0
MyInfoWidth = Lead1.BitmapWidth
MyInfoXRes = Lead1.BitmapXRes
MyInfoYRes = Lead1.BitmapYRes
'Save the image as raw FAX; then load the saved file.
'Format information will be supplied in the LoadInfo event.
Lead1.Save "c:\lead\images\tmp.tif", FILE_FAX_G3_2D, 1, 1, SAVE_OVERWRITE
Lead1.Load "c:\lead\images\tmp.tif", 0, 0, 1
'Repaint the newly loaded image.
Lead1.ForceRepaint
End Sub
4. Code the Lead1 control's LoadInfo event as follows:
Private Sub Lead1_LoadInfo()
'Use the form-level variables to supply format information.
Lead1.LoadInfoBits = MyInfoBits
Lead1.LoadInfoFlags = MyInfoFlags
Lead1.LoadInfoFormat = MyInfoFormat
Lead1.LoadInfoHeight = MyInfoHeight
Lead1.LoadInfoOffset = MyInfoOffset
Lead1.LoadInfoWidth = MyInfoWidth
Lead1.LoadInfoXRes = MyInfoXRes
Lead1.LoadInfoYRes = MyInfoYRes
End Sub
5. Run your program to test it.