|
-
Jan 27th, 2012, 02:36 PM
#11
Re: VS2010 - Out of memory exception while drawing
@llDayo
I tried your code. As it stands, it throws an OOM when I click Clear. The first thing I tried was to comment out your StartFigure statement, because it seems crazy to start a new figure every time you add a new pixel or two to the path. That cured the OOM, at least for now.
If you want to have separate figures, it would make sense to have one for each stroke. For example, if you enable drawing with the left mousebutton pressed, you could start a new figure in MouseDown and close it in MouseUp. If you are not using the mouse button for drawing, do it wherever you start and stop drawing a stroke, not in MouseMove.
I also tried commenting out PictureBox1.Image = bmp in the Paint event. The only effect was to stop clearing. So I moved that statement to the end of the ClearButton click sub, which looks to me to be a more logical place for it. That worked fine.
Finally, I commented out the Update statement. It won't make a big difference with a small picture box, but I find that drawing with the mouse is smoother when you use Invalidate alone. It did seem to me to make a slight improvement even here.
BB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|