Heya all!
I have a weird problem when creating a texture brush in a Paint event.
When program gets to the line where I'm creating a new TextureBrush object,
it crashes with OutOfMemory exception.
Here's the code:
private void pnl_DrawSurface_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
// Set InterpolationMode for image drawing
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
base.OnPaint (e);
// Draw previewImage onto the panel
if(this.previewImage != null)
{
this.displayRectangle = GetDisplayRectangle(this.previewImage);
this.CenterDisplayRectangle();
TextureBrush texBrush = new TextureBrush((Image)this.previewImage);
e.Graphics.FillRectangle(texBrush, this.displayRectangle);
}
}
Every object is valid (displayRectangle, previewImage ... they are not
nulls).
What a heck could be a problem here ???
Thanks in advance!