Available in the LEADTOOLS Imaging toolkit. |
FeedLoad example for Visual Basic
This example uses StartFeedLoad, FeedLoad, and StopFeedLoad and loads a file through a buffer to simulate receiving a transmitted image.
Private Sub FeedLoad_Click()
' Declare a buffer that you will use to feed the file-load process.
Const BUFFERSIZE = 1000
Dim MyArray(0 To BUFFERSIZE - 1) As Byte ' index the array starting with 0
' Declare other local variables.
Dim BytesRead As Long
Dim FileLength As Long
' Open an image file and get its length.
Open "c:\lead\images\image1.cmp" For Binary Access Read As #1
FileLength = LOF(1)
' Set PaintWhileLoad so that we can watch the progress.
Lead1.PaintWhileLoad = True
' Initialize the file-load process.
' Specify the default bits per pixel and first page
If Lead1.StartFeedLoad(0, 0, 1) <> 0 Then
MsgBox ("Error in StartFeedLoad !")
GoTo quit_function
End If
' Use FeedLoad in a loop to load the file into the bitmap.
Do
Get #1, , MyArray ' read from the file
If FileLength > BUFFERSIZE Then
BytesRead = BUFFERSIZE
Else
BytesRead = FileLength
End If
FileLength = FileLength - BytesRead
If Lead1.FeedLoad(MyArray, BytesRead) <> 0 Then
MsgBox ("Error in FeedLoad !")
GoTo quit_function
End If
Loop Until FileLength <= 0
' Finish the file-load process.
If Lead1.StopFeedLoad() <> 0 Then
MsgBox ("Error in StopFeedLoad !")
GoTo quit_function
End If
quit_function:
' Close the file.
Close #1
End Sub