Out of memory with MODI office 12

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

Ibrahim

Hi this is Ibrahim,
I found out that if i use the ToolBox and drop of an instance of the MODI
object onto my form and send messages from procesing thread to the ui thread,
i can process all the images i want with no exceptions as quickly as they can
be pumped.
Sometimes, we need to just do what these objects are designed for :).
thanks, hope someone else out there can benefit from this.
Bye for now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top