By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,933 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,933 IT Pros & Developers. It's quick & easy.

Loading big image. Please help.

P: n/a
Hello guys,

I hope you can help me. I have the following line in my code:

this.Butterfly = new Bitmap("c:\\butterfly.jpg");

which is pretty simple. The problem is that the size of butterfly.jpg
is 70 megs :) Of course, the program can't load it and i have the out
of memory exception.

My question is: how can I open that file? Please, give me some hints on
how to approach in this situation.

Thank you.

Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi...

There are several possibilities.

1. Look into using a Memory Mapped File. You may need to use Interop (not
sure if the framework implements wrappers).
2. Chunk your reading by using a Binary Stream. Open the Binary Stream and
read N bytes per chunk. As long as you have memory, stich the chunks
together until you complete reading in the entire file.
3. Save the image at a lower resoution/depth. Many times, JPEG files do
not degrade as quickly as you might anticipate.

John Puopolo
"woth" <vi***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello guys,

I hope you can help me. I have the following line in my code:

this.Butterfly = new Bitmap("c:\\butterfly.jpg");

which is pretty simple. The problem is that the size of butterfly.jpg
is 70 megs :) Of course, the program can't load it and i have the out
of memory exception.

My question is: how can I open that file? Please, give me some hints on
how to approach in this situation.

Thank you.

Nov 16 '05 #2

P: n/a
Firstly, what on earth do you need a 70MB jpeg of a butterfly for? ;)

Image Class size limit in GDI+ is 16Mb (2048x2048, 24bpp).

Let's say you want to display the image in a PictureBox on a WinForm. You
would actually need to create an algorithm to read chunks of the image into
a binary memory stream array. Then you would have to tile the pieces into a
series of Boxes keeping track of the alignment and order. You may end up
running out of system memory before its done!

In DirectX your texture size is limited by hardware. You can check your
D3DCaps to see what the max allowable is but I am sure you would still need
to chunkify and tile an image that large.

Remember, try microsoft.public.dotnet.framework.drawing for expertise on
gdi+...

ok,
aq

"woth" <vi***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello guys,

I hope you can help me. I have the following line in my code:

this.Butterfly = new Bitmap("c:\\butterfly.jpg");

which is pretty simple. The problem is that the size of butterfly.jpg
is 70 megs :) Of course, the program can't load it and i have the out
of memory exception.

My question is: how can I open that file? Please, give me some hints on
how to approach in this situation.

Thank you.

Nov 16 '05 #3

P: n/a
It is a big trouble. I think the bitmap class loads your jpeg into a bitmap
format. Suppose your jpeg has a 1:8 compression ratio. The bitmap is 560MB!
Do you think you can store such a class in your memory?
Try declaring a picturebox and write:
pictureBox1.Image = Image.FromFile("c:\\butterfly.jpg");
I doubt if this will work. If not, you need to learn the jpeg file format
and open the file with StreamReader and read some data each time.
"woth" wrote:
Hello guys,

I hope you can help me. I have the following line in my code:

this.Butterfly = new Bitmap("c:\\butterfly.jpg");

which is pretty simple. The problem is that the size of butterfly.jpg
is 70 megs :) Of course, the program can't load it and i have the out
of memory exception.

My question is: how can I open that file? Please, give me some hints on
how to approach in this situation.

Thank you.

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.