Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
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
Comments
Sergey Alexandrovich Kryukov 30-Jan-12 2:16am    
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.
--SA

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.

—SA
 
Share this answer
 
v2
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.)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900