Click here to Skip to main content
13,704,402 members
Rate this:
Please Sign up or sign in to vote.
Hi All,

In my application i need to display some large images which are having size of about 800MB.

When im trying to read the Image Using
Image img = Image.FromFile(filepath);
its showing OutOfMemory error.

Please help me. How to read large Images?
Posted 29-Jan-12 19:48pm
Good question, not an easy problem. You deserve to get some encouragement with my vote of 5. (Believe me, I do it very rarely.)
I hope I have a clear answer. You follow-up questions are welcome.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The situation is not easy at all. Here is some idea:

Take a computer which has enough memory where you can read it. Important: on this stage, you should use uncompressed images. Break the big image into N x M of smaller fragments of some easily managed size and safe these fragments as separate files.

Select different size of the same image and scale it down using 2-3 or more different scale factors. The smallest size of the image in pixels should be of the size of of some fairly small computer monitor or less. You should be able to load the whole file in the smallest resolution at once. Re-sample you image, scaling it down to that set of lower resolutions. As to the higher resolution steps, you might need to break the image in smaller fragments, too.

In this way, you will have all of your single image in different sizes, in pixels, and some sizes of higher resolution levels will be presented as a matrix of smaller images.

You never need to show the whole image in full resolution, because the screen size will not allow it anyway. You need to select the set of sized the way you can produce a "virtual image" for every given resolution and the view port requested by the user. The technique should resemble the technique of presentation of the Google Earth. Do you math. If you do it right, every view of your "virtual image" will need no more than 4 fragments of the image matrix at a time.

The only problem is image compression. If you use strong lossy compression like JPEG, you can see artifact of the edges between fragments. With more compression, you will see artifacts on the image anyway. So, I think you still can use lossy compression if you compress moderately.

Also, make compression only on the last step. You source code should be uncompressed (it's the best to use lostless compression). You final result should be compressed only once, always redo unsatisfactory results from scratch, from a lostless image. Repeated compression of the same image tend to accumulate artifacts and other defects.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If .NET does not support this size, you'll probably have to open and interpret the file content yourself.

What format are they ?

(There may be many answers to your question, please provide more input.)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web06-2016 | 2.8.180920.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100