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. Images loading and preview

Images loading and preview

Scheduled Pinned Locked Moved C#
csharpdata-structuresperformancetutorialquestion
4 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.
  • W Offline
    W Offline
    Werfu
    wrote on last edited by
    #1

    I'm currently writting an application and I need to load all images from a directory and display their thumbnails after. I'd need to change the preview list when the user click on another directory in the tree view, so I need to load those thumbnail fast. Currently I'm loading all those images one by one and I store them into an ImageList. I know this is not efficient and that the images stay open until the file handle is close. I'm worried about the possibility to run out of memory or of file handle if the garbage collector don't free those ressources soon enough. Do anybody have any idea how to handle efficiently images preview and loading in .Net 2.0? I've googled a lot, but didn't find anything doing it. In fast, I need an image viewer as fast as possible as I'm loading from memory card and other slow disk drive. Any idea? Let's discuss about .Net image capabilties.

    C L 2 Replies Last reply
    0
    • W Werfu

      I'm currently writting an application and I need to load all images from a directory and display their thumbnails after. I'd need to change the preview list when the user click on another directory in the tree view, so I need to load those thumbnail fast. Currently I'm loading all those images one by one and I store them into an ImageList. I know this is not efficient and that the images stay open until the file handle is close. I'm worried about the possibility to run out of memory or of file handle if the garbage collector don't free those ressources soon enough. Do anybody have any idea how to handle efficiently images preview and loading in .Net 2.0? I've googled a lot, but didn't find anything doing it. In fast, I need an image viewer as fast as possible as I'm loading from memory card and other slow disk drive. Any idea? Let's discuss about .Net image capabilties.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Ignore the garbage collector, you need to call Dispose on any image that you're throwing away. I believe it's possible to ask for a thumbnail when you call Bitmap.FromFile, or the constructor that takes a filename.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      1 Reply Last reply
      0
      • W Werfu

        I'm currently writting an application and I need to load all images from a directory and display their thumbnails after. I'd need to change the preview list when the user click on another directory in the tree view, so I need to load those thumbnail fast. Currently I'm loading all those images one by one and I store them into an ImageList. I know this is not efficient and that the images stay open until the file handle is close. I'm worried about the possibility to run out of memory or of file handle if the garbage collector don't free those ressources soon enough. Do anybody have any idea how to handle efficiently images preview and loading in .Net 2.0? I've googled a lot, but didn't find anything doing it. In fast, I need an image viewer as fast as possible as I'm loading from memory card and other slow disk drive. Any idea? Let's discuss about .Net image capabilties.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Two comments: - there is at least one other thread (by RajeshGuptha) concerning a large app with many images; Rajesh ended up creating separate thumbnail files, so I guess he does not open a full image unless it is really needed. - I had some trouble with Image.FromFile keeping the file open (although the entire image has been loaded in memory). So I decided to immediately copy the image and dispose of the one returned by FromFile. And, of course, please make sure to dispose of everything that has a Dispose() method ! Cheers,

        Luc Pattyn

        C 1 Reply Last reply
        0
        • L Luc Pattyn

          Two comments: - there is at least one other thread (by RajeshGuptha) concerning a large app with many images; Rajesh ended up creating separate thumbnail files, so I guess he does not open a full image unless it is really needed. - I had some trouble with Image.FromFile keeping the file open (although the entire image has been loaded in memory). So I decided to immediately copy the image and dispose of the one returned by FromFile. And, of course, please make sure to dispose of everything that has a Dispose() method ! Cheers,

          Luc Pattyn

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Luc Pattyn wrote:

          - I had some trouble with Image.FromFile keeping the file open (although the entire image has been loaded in memory). So I decided to immediately copy the image and dispose of the one returned by FromFile.

          Yes, this is a known issue, a wrapper method that copies and closes the original is a good idea, if you may want to save over an image you've loaded and edited.

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          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