|
-
Feb 8th, 2012, 05:54 PM
#1
Thread Starter
Addicted Member
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.
-
Feb 8th, 2012, 07:15 PM
#2
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.
-
Feb 8th, 2012, 07:56 PM
#3
Thread Starter
Addicted Member
Re: Loading Extremely large(dimension) images.
uploading.. 20mins to go (killer uploading speed )
-
Feb 8th, 2012, 08:15 PM
#4
Thread Starter
Addicted Member
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.
-
Feb 8th, 2012, 10:33 PM
#5
Thread Starter
Addicted Member
Re: Loading Extremely large(dimension) images.
-
Feb 9th, 2012, 05:09 AM
#6
Hyperactive Member
Re: Loading Extremely large(dimension) images.
-
Feb 9th, 2012, 05:25 AM
#7
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.
-
Feb 9th, 2012, 05:30 AM
#8
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.
-
Feb 9th, 2012, 08:41 PM
#9
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|