I need to write a program to reduce the size of some large images(13200x20394 1bpp png images). In my sample set of 10 I can process 4 before I get an "Out of memory" error. I am running 32bit windows XP pro with the maximum amount of ram installed.

I get the error on the line that reads: g.DrawImage(....
Here is the code I am using to resize the image:

private Bitmap ResizeBmp(Bitmap bm, int newWidth, int newHeight)
{
Bitmap newbmp = new Bitmap(newWidth, newHeight);
try
{
Graphics g = Graphics.FromImage((Image)newbmp);
try
{
//this is the line that throws the error
g.DrawImage(bm, new Rectangle(0, 0, newWidth, newHeight), 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel);

}
catch(Exception ex)
{
setError(ex.Message, -1);
}
g.Dispose();
}
catch(Exception ex)
{
setError(ex.Message, -1);
}

return newbmp;
}

Why do I get a memory error like this?
I have not seen problems with small png images.

Thanks