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 LEAD RasterProcess Object Library to your project.

 

On the Project pull-down menu, use the References option, and select the LEAD RasterProcess Object Library (14.5).

3.

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
Private WithEvents RasterIO As LEADRasterIO

4.

Add the following to the Form Load event handler:

'Create the RasterIO Object
Set RasterIO = CreateObject("LEADRasterIO.LEADRasterIO. ")

5.

image\btncmd.gif Add a CommandButton control and code its click procedure as follows:

Private Sub Command4_Click()
    Dim RasterProc As New LEADRasterProcess
    LEADRasterView1.ScaleMode = 3 'Pixels
    'Make the image look OK as a 1-bit image.
    RasterProc.Size LEADRasterView1.Raster, _ 
                              LEADRasterView1.ScaleWidth, _
                              LEADRasterView1.ScaleHeight, RESIZE_RESAMPLE
    RasterProc.Halftone LEADRasterView1.Raster, 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 = LEADRasterView1.Raster.BitmapHeight
    MyInfoOffset = 0
    MyInfoWidth = LEADRasterView1.Raster.BitmapWidth
    MyInfoXRes = LEADRasterView1.Raster.BitmapXRes
    MyInfoYRes = LEADRasterView1.Raster.BitmapYRes
    'Save the image as raw FAX; then load the saved file.
    'Format information will be supplied in the LoadInfo event.
    RasterIO.Save LEADRasterView1.Raster, "d:\temp\tmp.tif", FILE_FAX_G3_2D, _
                  1, 1, SAVE_OVERWRITE
    RasterIO.Load LEADRasterView1.Raster, "d:\temp\tmp.tif", 0, 0, 1
    'Repaint the newly loaded image.
    LEADRasterView1.ForceRepaint
End Sub

6.

Code the RasterIO object's LoadInfo event as follows:

    'Use the form-level variables to supply format information.
    RasterIO.LoadInfoBits = MyInfoBits
    RasterIO.LoadInfoFlags = MyInfoFlags
    RasterIO.LoadInfoFormat = MyInfoFormat
    RasterIO.LoadInfoHeight = MyInfoHeight
    RasterIO.LoadInfoOffset = MyInfoOffset
    RasterIO.LoadInfoWidth = MyInfoWidth
    RasterIO.LoadInfoXRes = MyInfoXRes
    RasterIO.LoadInfoYRes = MyInfoYRes

7.

Run your program to test it.