ImageList/List View Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikeymike
    New Member
    • Jul 2009
    • 12

    ImageList/List View Help

    Hi guys,
    I am loading a series of JPG images into an image list then using that to fill a list view. My program is using ALOT of memory by doing this. What would be the easiest way to add the images but take up less memory/time?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    It's going to take as much memory as you decide to keep.
    If you keep a lot of images at their full size, then that's how much memory you need. Average camera image is 5mp these days. If you keep 100 of them... 500meg of RAM. If you keep them in a List<> and a duplicate set of them in the ListView... that's a gig of RAM.

    If you don't need the full 5mp image for a 200pixel x 200pixel view then scale it down. Make a new list of scaled down images, discarding the full size image as you go.

    If you don't need the images in BOTH the list, and the list view, then dump what you aren't using.

    Comment

    • mikeymike
      New Member
      • Jul 2009
      • 12

      #3
      Originally posted by tlhintoq
      It's going to take as much memory as you decide to keep.
      If you keep a lot of images at their full size, then that's how much memory you need. Average camera image is 5mp these days. If you keep 100 of them... 500meg of RAM. If you keep them in a List<> and a duplicate set of them in the ListView... that's a gig of RAM.

      If you don't need the full 5mp image for a 200pixel x 200pixel view then scale it down. Make a new list of scaled down images, discarding the full size image as you go.

      If you don't need the images in BOTH the list, and the list view, then dump what you aren't using.
      Sorry I'm pretty new to this. What i'm currently doing is as the user choses images i clear the imagelist and load them to it. Then load each image to the listview. The images are generally big, how could I scale them down? Can i load them straight to the imageview.. I tried this but couldnt get it to work thats why i went this path

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        You definatley don't want to just load large images straight into any control.
        That might be easy on you, the programmer, but it puts all the burden on the control.

        Look at it this way. You can take a graphic 1000 x 1000 pixels and send it to a PictureBox that is only 100x100. If you set the PictureBox image style to "Zoom" then the PictureBox will do some internal magic to show you 1000x1000 inside 100x100... but the image that the PictureBox retains is still the 1000x1000 image. Just because it shows you the 100x100 doesn't mean it isn't eating up 10 times that in RAM.

        For each image you read, you need to create a new, scaled down image of the size you intend to display.

        Read up on the System.Drawing namespace in the MSDN.
        Do some googling for "C# image scaling".
        There are a lot of good tutorials on it that cover it in a lot more depth than I can here.

        There are several different techniques that yield a variety of results. Do you need color-corrected accuracy? Do you need fast? Can you sacrifice color-depth for speed and RAM?

        You'll have to balance your needs against what you can afford to sacrifice. Clarity for scalability. etc.

        Comment

        Working...