Graphics.DrawImage consuming more memory ???

A

Aravind

Hi,

I am trying to create a image object out of a bitmap file like
Image img = new Bitmap(@"c-\CurDisplayImage.bmp"); ,I found the memory
of the process is increased twice as the bitmap size , for example if I
load a 50MB bitmap the memory is increased by 100MB ,
Also when I draw the image with e.Graphics.DrawImage ,the Peak memory
is reaching to several hundred MB , so when I am dealing with some high
resolution image I am often getting out of memory exception . Any way
to solve this issue ??

Thanks in Advance

Regards
Aravind.
 
N

Nicholas Paldino [.NET/C# MVP]

Aravind,

My guess is that when you load the image into memory, GDI+ is allocating
the memory it needs to store the image. Then, when you start to draw to the
image, it creates a new image buffer of the same size (hence the doubling of
the memory).

There isn't much you could do here, unless you can break the image down
into smaller images and process those. Either that, or get more memory.

Hope this helps.
 

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