TextureBrush Out Of Memory Exception

G

Guest

Hello,

Hopefully someone here can help me. I'm not sure what I am doing wrong, but
I am getting an Out Of Memory exception when I try to use a TextureBrush. I
have simplified my code to reproduce this error. Here is the code:

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs
e)
{
Bitmap bmp = new Bitmap(@"C:\myimage.gif");
Rectangle rect = new Rectagle(10, 10, 100, 50);
TextureBrush brush = new TextureBrush(bmp, rect);
e.Graphics.FillRectangle(brush, rect);
}

The exception is thrown on the TextureBrush constructor. I have also found
that if I do not set the Rectangle parameter it works just fine, but then of
course my image is displayed at Point(0, 0) rather than Point(10, 10) where I
want it to begin.

I have searched for an answer to this and found nothing so I'm sure it must
be something simple I am doing wrong. Any help would be greatly appreciated.

Thanks,
Dave
 

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