Google Groups Home
Help | Sign in
performance woes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
David Smith  
View profile
 More options Sep 27 2005, 4:49 pm
From: David Smith <smith...@gmail.com>
Date: Tue, 27 Sep 2005 16:49:51 -0400
Local: Tues, Sep 27 2005 4:49 pm
Subject: performance woes

Hi guys,
 This code seems to be running pretty slow (about 1 second / image)

dlgOpen.ShowDialog()
ListView1.BeginUpdate()
ListView1.AutoArrange = False
ImageList1.Images.Clear()
ListView1.Items.Clear()
Dim fileSys As System.IO.Directory
Dim intCountPaths As Integer = 0
For Each path As String In fileSys.GetFiles(dlgOpen.SelectedPath)
Dim fileProps As New System.IO.FileInfo(path)
If LCase(fileProps.Name).EndsWith(".jpg") Then
ImageList1.Images.Add(System.Drawing.Image.FromFile(dlgOpen.SelectedPath &
"\" & fileProps.Name))
ListView1.Items.Add(fileProps.Name, intCountPaths)
ListView1.Items(intCountPaths).Tag = dlgOpen.SelectedPath & "\" &
fileProps.Name
intCountPaths += 1
End If
Next path
ListView1.EndUpdate()

Any ideas on how to speed things up?

Thanks!

--dave
_________________
David Smith

(517) 944-1872
smith...@msu.edu
614 Theo
Lansing MI 48917


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "GLUGnet :: performance woes" by David J. Smith
David J. Smith  
View profile
 More options Sep 28 2005, 11:36 pm
From: "David J. Smith" <davidjsm...@gmail.com>
Date: Wed, 28 Sep 2005 20:36:22 -0700
Local: Wed, Sep 28 2005 11:36 pm
Subject: RE: GLUGnet :: performance woes

I copied the code into a new project and everything is quick as a fox to me.
Try it out!  =)

If you want more freedom with what you do, (e.g. the max imagesize on an
imagelist is 256 pixels.), you may want to try out creating your own custom
thumbnail view from a PictureBox, and a label. =)

If this code doesn't work, you may want to look at your image size.

I'm curious - How big are the images you're dealing with? (These are itty
bitty jpegs after all)

On the Form, we have:

A  ListView named listView1.

An ImageList named imageList1.

A button named button1.

A FolderBrowserDialog named folderBrowserDialog1.

private void button1_Click(object sender, EventArgs e)

        {

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)

            {

                DirectoryInfo targetDirectory = new
DirectoryInfo(folderBrowserDialog1.SelectedPath);

                listView1.BeginUpdate(); // don't update the listview state
as we change things

                listView1.AutoArrange = false;

                listView1.Items.Clear(); // reset the listview, let's start
loading images from scratch

                imageList1.Images.Clear(); // reset the imagelist, let's
start loading images from scratch

                imageList1.ColorDepth = ColorDepth.Depth32Bit; // 4 - 32
color depth

                imageList1.ImageSize = new Size(100, 100);  // this can vary
from 1 - 256 inclusive

                int countPaths = 0; // index into the number of images we've
added so far

                                                                        //
Go through all the files in a directory

                foreach (FileInfo file in targetDirectory.GetFiles()) // Not
a performance hit since the JIT does performance optimizations.

                {

                    if (file.Extension == ".jpg") // Apparently, jpegs are
important to us. ((file.Extension == ".jpg") || (file.Extension == ".gif"))
to add gif support

                    {

imageList1.Images.Add(Image.FromFile(folderBrowserDialog1.SelectedPath +
@"\" + file.Name));

                        listView1.Items.Add(file.Name, countPaths);

                        listView1.Items[countPaths].Tag =
folderBrowserDialog1.SelectedPath + @"\" + file.Name;

                        countPaths++;

                    }

                }

                listView1.View = View.LargeIcon;  // Display images for each
item in the listview

                listView1.LargeImageList = imageList1;  // Bind the
ImageList to the listView. (*Important*)

                listView1.EndUpdate(); // Start rendering the listview
again.

            }

}

Cheers!

David J. Smith

Visual C# MVP

smith...@msu.edu

  _____  

From: GLUGnet@googlegroups.com [mailto:GLUGnet@googlegroups.com] On Behalf
Of David Smith
Sent: Tuesday, September 27, 2005 1:50 PM
To: GLUGnet@googlegroups.com
Subject: GLUGnet :: performance woes

Hi guys,

This code seems to be running pretty slow (about 1 second / image)

dlgOpen.ShowDialog()
        ListView1.BeginUpdate()
        ListView1.AutoArrange = False
        ImageList1.Images.Clear()
        ListView1.Items.Clear()
        Dim fileSys As System.IO.Directory
        Dim intCountPaths As Integer = 0
        For Each path As String In fileSys.GetFiles(dlgOpen.SelectedPath)
            Dim fileProps As New System.IO.FileInfo(path)
            If LCase(fileProps.Name).EndsWith(".jpg") Then

ImageList1.Images.Add(System.Drawing.Image.FromFile(dlgOpen.SelectedPath &
"\" & fileProps.Name))
                ListView1.Items.Add(fileProps.Name, intCountPaths)
                ListView1.Items(intCountPaths).Tag = dlgOpen.SelectedPath &
"\" & fileProps.Name
                intCountPaths += 1
            End If
        Next path
        ListView1.EndUpdate()

Any ideas on how to speed things up?

Thanks!

--dave
_________________
David Smith

(517) 944-1872
smith...@msu.edu
614 Theo
Lansing MI 48917


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google