Not able to load 23 MB PNG File in Bitmap Class

A

Anand Ganesh

Hi All,

I am trying to load 23 MB PNG file using the Bitmap Class, but I am getting
an out of memory exception.

My computer has 1 GB RAM and 1.5 GB Virtual Memory but still I am getting
this error. The Image file is not corrupted and I am able to see the Image
in the Windows Picture Viewer.

Any clues on how to load this Image in Memory?

Thanks
Anand Ganesh

Here is my code

try

{

Bitmap TheImage = new
Bitmap(@"C:\GV7TestService\SIDSpot\mrsiddecode_win\AhmedBIG.PNG") ;

bool ImageLoaded = true ;

TheImage.Dispose() ;

}

catch(Exception ex)

{

MessageBox.Show(ex.ToString()) ;

}
 
B

Bruce Wood

Note that .NET probably does not store the file internally in the same
format as read. In fact, it almost ceratainly doesn't. At the very
least it makes a copy of the whole thing and builds a bitmap of it.

In particular, .NET's graphics classes support only a couple of bit
depths for pixels. I know for a fact that reading a TIFF with 4 bpp
grayscale results in massive memory bloat inside .NET, as it builds a
bitmap with at least 16 bpp, if not 32 (I can't recall at the moment).

I don't know if graphics handling has improved at all in .NET 2.0. I
rather suspect that they're going to wait for Avalon to get it right.
 
A

Anand Ganesh

Thanks Bruce.

Atleast this gives an idea on which way to proceed.

Regards
Anand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top