I
Ibrahim
Hi,
I need to use MODI to read a number of TIFF files check the compression of
the images in the files and then OCR a section of each image. Currently, i
have only implemented the code that reads the compression but Visual Studio
2005 gives me out of memory exception after it reads 477 files. Also this
number decreases each time i run the application. I have included the code i
have implemented below to see if anyone can come up with anything why this is
doing what it is doing. As you can see, i have not used the MODI object to be
part of my form, i just declared and instatiated it in code as you can see:
Private Function GetTifCompression(ByVal fileName As String, _
ByRef imageCompression As
MODI.MiCOMP_TYPE, _
ByRef imageNumber As Integer) As
Boolean
Dim result As Boolean = False
Dim imageIndex As Integer
Dim tiffDoc As MODI.Document = Nothing
Dim tiffImage As MODI.Image = Nothing
Dim tiffLayout As MODI.Layout = Nothing
Try
tiffDoc = New MODI.Document()
tiffDoc.Create(fileName)
tiffDoc.OCR(MiLANGUAGES.miLANG_ENGLISH)
Dim numImages As Integer = tiffDoc.Images.Count
If numImages > 1 Then
SendMessage(DISPLAY_ID.PROPGRESS, ".....There are more than
one image in this file.")
End If
If numImages <> 0 Then
For imageIndex = 0 To numImages - 1
' Each image in the TIFF file has its own compression
tiffImage = tiffDoc.Images(imageIndex)
tiffLayout = tiffImage.Layout()
imageCompression = tiffImage.Compression
imageNumber = imageIndex
result = True
Next
End If
Catch ex As Exception
SendMessage(DISPLAY_ID.FINAL_RESULT_ERROR, _
"Exception occured in reading the TIFF image : <" &
ex.Message & ">.")
Finally
tiffDoc.Close()
tiffLayout = Nothing
tiffImage = Nothing
tiffDoc = Nothing
End Try
Return result
End Function
I need to use MODI to read a number of TIFF files check the compression of
the images in the files and then OCR a section of each image. Currently, i
have only implemented the code that reads the compression but Visual Studio
2005 gives me out of memory exception after it reads 477 files. Also this
number decreases each time i run the application. I have included the code i
have implemented below to see if anyone can come up with anything why this is
doing what it is doing. As you can see, i have not used the MODI object to be
part of my form, i just declared and instatiated it in code as you can see:
Private Function GetTifCompression(ByVal fileName As String, _
ByRef imageCompression As
MODI.MiCOMP_TYPE, _
ByRef imageNumber As Integer) As
Boolean
Dim result As Boolean = False
Dim imageIndex As Integer
Dim tiffDoc As MODI.Document = Nothing
Dim tiffImage As MODI.Image = Nothing
Dim tiffLayout As MODI.Layout = Nothing
Try
tiffDoc = New MODI.Document()
tiffDoc.Create(fileName)
tiffDoc.OCR(MiLANGUAGES.miLANG_ENGLISH)
Dim numImages As Integer = tiffDoc.Images.Count
If numImages > 1 Then
SendMessage(DISPLAY_ID.PROPGRESS, ".....There are more than
one image in this file.")
End If
If numImages <> 0 Then
For imageIndex = 0 To numImages - 1
' Each image in the TIFF file has its own compression
tiffImage = tiffDoc.Images(imageIndex)
tiffLayout = tiffImage.Layout()
imageCompression = tiffImage.Compression
imageNumber = imageIndex
result = True
Next
End If
Catch ex As Exception
SendMessage(DISPLAY_ID.FINAL_RESULT_ERROR, _
"Exception occured in reading the TIFF image : <" &
ex.Message & ">.")
Finally
tiffDoc.Close()
tiffLayout = Nothing
tiffImage = Nothing
tiffDoc = Nothing
End Try
Return result
End Function