Hi There, I need a little help.
I have a class uses the PictureBox as a base.
In this I want to store the current image twice. So I can restore the image
when needed.
Right now I create another Image object and when the user hits an apply
button it saves the current image into the second image. I use the
following:
undoImage = (System.Drawing.Image)this.Image.Clone();
That line appears to work, but my next section causes an
OutOfMemoryException Error:
using (Graphics g = Graphics.FromImage(this.Image))
{
g.FillRectangle(myBrush, myRectangle);
this.Invalidate();
g.Dispose();
}
What I don't understand is that if I comment out the line that makes a clone
of the image it works fine.
Does anyone know how to do this, or a different way or why this would cause
a out of memory exception?
Thanks,
Steve