Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB.NET 2005 to 2008 but still windows 2.0? Image object problem.

Hi,
I just used VS2008 and migrated a project from 2005 to
2008. The reason is that MSDN docs is saying the Image
object in .NET Framework 3.5 has a Finalize method, which i
want to try out since my app is processing a few image
files and then saying it is running out of memory. I am
using the Dispose method of this object to get rid of it
and then setting it to Nothing. in any case, when i used VS
2008, intellisense still does not show the Finalize method
as one of the methods of the object. Any idea why it is
still using the Image object from .net framework 2.0?
Please see code below:
thanks,
Mars


Private Function EvaluateTiffImage(ByRef displayObject
As ThreadMessageClass, ByVal fileName As String, _

ByVal startingPageNum As String, ByVal fileExt As String)
As Boolean

Dim result As Boolean = False

' count of images in the tiff file
Dim imageIndex As Integer = 0

Dim propertyValues As Byte() = Nothing
Dim compressionString As String = ""
Dim compressionValue As Int16 = 0
Dim tiffImage As Image = Nothing

displayObject.TargetWindow =
DISPLAY_ID.LIST_PROGRESS

Dim tiffData As TiffProcessingDataClass =
displayObject.MessageData

Try

' using the Imaging Managed objects
tiffImage = Image.FromFile(fileName)

If Not (tiffImage Is Nothing) Then

Dim propertyItems As
System.Drawing.Imaging.PropertyItem() =
tiffImage.PropertyItems

For propertyIndex As Integer = 0 To
propertyItems.Length

' Compression property has an id of 259
If propertyItems(propertyIndex).Id() =
259 Then

' The value of which is mapped to a
short type (i.e. Int16)
propertyValues =
propertyItems(propertyIndex).Value

' most significant bit is at higher
index
compressionString =
propertyValues(1) & propertyValues(0)
compressionValue =
Convert.ToInt16(compressionString)

tiffData.ImageCompression =
compressionValue

If ((compressionValue =
IMAGE_COMPRESSION.COMPRESSION_CCITTFAX4) And (fileExt =
".tif")) Or _
((compressionValue =
IMAGE_COMPRESSION.COMPRESSION_HUFFMAN_CCITTRLE) And
(fileExt = ".jpg")) Then

result = True
displayObject.MessageText =
"...Found " & GetCompressionName(compressionValue) & "
Compression for: <" & fileName & "."

Else
displayObject.MessageText =
"...Error: " & GetCompressionName(compressionValue) & "
Compression: <" & fileName & "."
displayObject.IsError = True
End If
DisplayMessage(displayObject)

' found what we are looking for
Exit For
End If
Next

Application.DoEvents()

' release the reference to the image object
imageIndex += 1

Else

displayObject.MessageText = "...Error: GDI+
error was unable to create a document for <" & fileName &
"."
displayObject.IsError = True
DisplayMessage(displayObject)

End If
Catch ex As Exception

Dim innerExceptionString As String = Nothing

If ex.InnerException Is Nothing Then
innerExceptionString = "No inner exception"
Else
innerExceptionString =
ex.InnerException.InnerException.Message
End If

displayObject.MessageText = "An exception
occurred: <" & ex.Message & ", this error happened when "
& _

"Procedo was trying to process file: <" & fileName & "
inner exception: <" & _

innerExceptionString & "."
displayObject.IsError = True
displayObject.TargetWindow =
DISPLAY_ID.LIST_RESULT
DisplayMessage(displayObject)

Finally

If tiffImage IsNot Nothing Then
' tiffImage.Finalize() this line has a
syntax error when it is uncommented
tiffImage.Dispose()
tiffImage = Nothing
End If

End Try

Return result
End Function


*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 file locked by 'another user' on windows 2008 share Hansvb Excel Discussion (Misc queries) 0 December 7th 09 11:49 AM
I Keep Installing Ubuntu And Vista And Windows 2008 Server, Just FYI kevpan815 Excel Programming 0 June 17th 08 04:30 AM
MS VB 2005 / 2008 EXPRESS EDITION S3GANESH Excel Programming 2 April 17th 08 11:01 PM
0x800a03ec - VB 2005 or VB 2008 & Excel 2007 (Range Text) (AddData Stephen Plotnick[_2_] Excel Programming 0 March 28th 08 02:09 AM
How to Add an Object to the New Object List in windows 2000 Bubu Excel Programming 5 June 3rd 04 12:42 PM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"