c# - Most effective way to redraw image -


i'm making simple 2d game. unfortunately ran issue refresh rate when add images. use invalidate on timer tick works fine until change drawrectangle drawimage. 27 objects on screen paint refresh rate drops stable 64 39 on average. images use 2-3kb shouldn't cause issue. please me understand this. why , how happen? causes , issues , how fix it?

perfectly fine:

foreach (ground _en in game.blocks) {     e.graphics.fillrectangle(brushes.green,_en.rec); } 

causes frame drop:

foreach (ground _en in game.blocks) {     e.graphics.drawimage(image.fromfile(_en.background), _en.rec); } 

you're loading file memory hard disk each time call .fromfile(). store image in ground class on instantiation (or whenever, not when calling in draw()) , should fixed.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -