Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Loading thumbnails in listview.....faster way?

Loading thumbnails in listview.....faster way?

Scheduled Pinned Locked Moved C#
helpquestionwinformsperformance
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abcxyz82
    wrote on last edited by
    #1

    I have windows forms application, where user can select images to be loaded from FileDialog. It creates thumbnails of those and displayes them in listview...its taking longer then expected. Users generally select 30-35 200DPI .jpeg images. I am using Imagelist & Listview combination....I think problem is of windows painting(invalidate or refresh)...I do beginUpdate,endUpdate before and after adding items. How can i boost performance of this task? Any help will greatly be appriciated.. Regards, MaulikCE

    D L 2 Replies Last reply
    0
    • A abcxyz82

      I have windows forms application, where user can select images to be loaded from FileDialog. It creates thumbnails of those and displayes them in listview...its taking longer then expected. Users generally select 30-35 200DPI .jpeg images. I am using Imagelist & Listview combination....I think problem is of windows painting(invalidate or refresh)...I do beginUpdate,endUpdate before and after adding items. How can i boost performance of this task? Any help will greatly be appriciated.. Regards, MaulikCE

      D Offline
      D Offline
      Douglas Troy
      wrote on last edited by
      #2

      1. Make sure all your images already contain an embedded Thumbnail image 2. Only load those images in the visible area (in other words, don't load them all, only what the user can see on the screen) 3. Thread it so the loading process doesn't "tag" your window

      1 Reply Last reply
      0
      • A abcxyz82

        I have windows forms application, where user can select images to be loaded from FileDialog. It creates thumbnails of those and displayes them in listview...its taking longer then expected. Users generally select 30-35 200DPI .jpeg images. I am using Imagelist & Listview combination....I think problem is of windows painting(invalidate or refresh)...I do beginUpdate,endUpdate before and after adding items. How can i boost performance of this task? Any help will greatly be appriciated.. Regards, MaulikCE

        L Offline
        L Offline
        Libor Tinka
        wrote on last edited by
        #3

        You have to save your thumbnail images and just load them next time except shrinking the original images again and again. Thumbnails can be stored in some pre-defined directory with hashed filenames. I have developed such very standard system of storing thumbnails based on MD5 hashing. It works this way: 1. Check if the image is small enough (no need to create thumbnail => return) 2. Create MD5 hash from image's FULL path (C:\My Documents\Pictures\ ...) 3. Look to your Thumbnails directory, if there is a thumbnail created 3.1 Yes, load thumbnail 3.2 No, create thumbnail and save it in Thumbnails directory This is my method for generating MD5 from path string (it returns MD5 in hex format): using System.Security.Cryptography; using System.Text; ... // generate MD5 path protected string HashPath(string path) { ASCIIEncoding enc = new ASCIIEncoding(); MD5 md5 = MD5CryptoServiceProvider.Create(); byte[] buffer = md5.ComputeHash(enc.GetBytes(path)); string hashPath = ""; for (int i = 0; i < buffer.Length; i++) hashPath = hashPath + String.Format("{0:X2}", buffer[i]).ToLower(); return parentPanel.hashDirectory + hashPath + ".jpg"; } ...and of course, optimize your code of thumbnail creation. Use fast GDI+ filters for resampling images and put it all on background separate thread. Hope this helps :-D

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups