Results 1 to 9 of 9

Thread: Loading Extremely large(dimension) images.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    177

    Loading Extremely large(dimension) images.

    I'm trying to load this image file on a PictureBox but I get an "OutOfMemoryException was unhandled" error.


    How do I allocate more memory for this? Or maybe use another container? My project's main feature is loading maps, unfortunately my boss wants to load the whole map and won't accept sliced version of the map.
    Last edited by m.davide; Feb 8th, 2012 at 05:58 PM.

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Loading Extremely large(dimension) images.

    Upload that image to a file server or something so I can download it and experiment with it. Ive never had to deal with an image that large.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    177

    Re: Loading Extremely large(dimension) images.

    uploading.. 20mins to go (killer uploading speed )

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    177

    Re: Loading Extremely large(dimension) images.

    https://rapidshare.com/files/3399547128/CdoCitypng.png

    and btw, this is the code i used:

    Code:
    mainMenuFrm.map_picbox.Image = System.Drawing.Image.FromFile(loadDiag.FileName)
    Last edited by m.davide; Feb 8th, 2012 at 08:34 PM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    177

    Re: Loading Extremely large(dimension) images.

    anyone?

  6. #6
    Hyperactive Member
    Join Date
    Jul 2011
    Posts
    278

    Re: Loading Extremely large(dimension) images.

    That's a big picture.

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Loading Extremely large(dimension) images.

    I think what you'd normally do with this kind of huge images is create smaller versions of it. Sort of like mipmaps if you have ever done any 3D graphics.

    Continuing on the mipmap-idea.. you would take your huge image and create a smaller version of it by decreasing its width and height by 50% each time. This would give you a series of images, each one approximately 1/4th of the previous image size.

    When showing the map, use the appropriate image. If you arent showing the image on a 1:1 scale in the application, there is no need to load the huge bitmap when you only want to show a portion of it, scaled down. Load one of the smaller ones. You'll have to write some logic to determine which one to load.

    That would still not be enough though. I think you will still need to find exactly what portion of the image that should be displayed based on the "viewport", and only read that part into memory. Otherwise you'd end up with the same problem when viewing the map on a 1:1 scale, thus needing to load the full-sized map again.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  8. #8
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Loading Extremely large(dimension) images.

    Another thing you could do to ease on the memory consumption is converting the image to use less bits-per-pixel. I have not looked at your image but assuming that it is 32bpp, it would require 4 bytes per pixel:
    28625 * 22500 * 4 = 2576250000 bytes (approximately 2.5 GB).
    If you can not decrease the dimensions, the only thing you can change in this equation is the color-depth.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    177

    Re: Loading Extremely large(dimension) images.

    Thank you for the input. I might do the view port option.
    Just load a 1000x800 portion of the original image each time the user scrolls.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width