"Out of Memory" on Graphics.FromImage()

  • Thread starter Thread starter yotaxp
  • Start date Start date
Y

yotaxp

Hello, all.

This line has been pestering me, and I can't seem to figure out why the
problem is occuring. I'm trying to paint a GraphicsPath onto a Bitmap,
using the Graphics class, but it always seems to crash, and throw the
"Out of Memory" exception when it comes to the point I need the create
the object. I've been fairly strict with IDisposable.Dispose(), and
the 'using' as well. It always seems to be at this exact line, when
the exception is thrown, no matter how much memory I seem to have. I
have no recursive procedures, and this isn't at all deep within the
call stack (6 in, according to the debugger). The bitmap is pretty
large, at 6400x4800x16, but the same problem exists at 800x600x16.
 
Hello, all.

This line has been pestering me, and I can't seem to figure out why the
problem is occuring. I'm trying to paint a GraphicsPath onto a Bitmap,
using the Graphics class, but it always seems to crash, and throw the
"Out of Memory" exception when it comes to the point I need the create
the object. I've been fairly strict with IDisposable.Dispose(), and
the 'using' as well. It always seems to be at this exact line, when
the exception is thrown, no matter how much memory I seem to have. I
have no recursive procedures, and this isn't at all deep within the
call stack (6 in, according to the debugger). The bitmap is pretty
large, at 6400x4800x16, but the same problem exists at 800x600x16.

Guess your problem is due to the pixelformat, the PixelFormat16bppARGB1555,
and PixelFormat16bppGrayScale are not supported by GDI+.

excerp from Image.FromFile documentation:
Remarks:
If the file does not have a valid image format or if GDI+ does not support
the pixel format of the file, this method throws an OutOfMemoryException
exception.




Willy.
 
Yep, that did it. Figures, PixelFormat16bppARGB1555 was the perfect
format for what I'm trying to do. Any idea if, and when this (and the
other GDI+ glitches) will be corrected?
 

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

Back
Top