469,631 Members | 1,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

ListView and ImageList hogging memory - what to do?

I am working on an application that includes a feature where a
directory is spidered and thumbnails are displayed. I have it pretty
much down, but when the bitmaps are loaded from file, memory is hogged
like crazy. I know this is where the memory problems occur because
I've gone through that whole comment/check the ram thing. Here's the
source of where the problem occurs:

Public Shared Sub FillImageList(ByVal dir As String, ByVal ListView As
If Directory.Exists(dir) Then
'Get the files in an array and
'figure out how many there are
Dim file As String
Dim files() As String = Directory.GetFiles(dir)
Dim cleanfiles(files.Length) As String
Dim i As Integer = 0
For Each file In files
If Regex.IsMatch(file.ToString,
"[^<.*>.*](.jpg|.JPG|.jpeg|.JPEG|.png|.PNG|.gif|.GIF|.tif|.T IF|.bmp|.BMP)")
cleanfiles(i) = file.ToString
i = i + 1
End If

'Create a thumbnail for every image and add it to the
If cleanfiles.Length > 0 And cleanfiles(0) <> "" Then
Dim h As Integer = 0
For Each file In cleanfiles
If file <> "" Then
Dim objImage As Image
' Open the image
objImage = New Bitmap(file)

' Convert the image to a thumbnail. This is
' than the longer convert/compress to JPEG I
' using before.
objImage = objImage.GetThumbnailImage(100,
100, Nothing, New IntPtr)

'Add the thumbnail to the image list
'Add the filename as the text
'Attach the image to the text
ListView.Items(h).ImageIndex = h
h = h + 1
End If

End If
End If
End Sub
Any help would be very greatly appreciated. Reply here or email
pu****@putnamplanet.com. Thanks!

Nov 20 '05 #1
0 2075

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Silvia | last post: by
3 posts views Thread by Ian | last post: by
reply views Thread by Silvia | last post: by
1 post views Thread by Steve | last post: by
4 posts views Thread by Archimed | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.