c# - How to delete an image from Graphics -


suppose use drawimage few times draw bunch of images.

e.graphics.drawimage(newimage, destrect);

how can delete specific image graphics paper drew on? there specific function can use deletion?

i have tried dispose , rectangle.empty, don't delete image drew on paper.

first of all, there's no concept of "delete object" in gdi+ graphics. have redraw the entire client area in every frame. should keep list of objects , states in memory , redraw entire surface in every frame. beware though, can lead flickers , not-so-smooth user experience. here few tips avoid these:

  1. make sure form or usercontrol has doublebuffered property set true. result in far smoother animation otherwise.

  2. never ever call creategraphics() reference graphics object in drawing loop. update list of objects , states in loop , call invalidate() on control/form , drawing process in paint event.

  3. one overload of invalidate() allows specify rectangle needs invalidated (redrawn). can pass "safe" rectangle around bouncing ball's current position (say 20 pixels wider/taller ball size) agrument , draw portion in paint event.

  4. to further increase performance can keep auxilary information such scores, player names etc. outside actual "game board" , use normal labels/textboxes them instead of drawing.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -

java Extracting Zip file -