java - Rotating bitmap in main game loop without overloading GC in Android -


what correct way rotate bitmap every frame in main game loop? have tried:

i created rotated bitmap every frame:

bitmap image, tmp; matrix m; ... public void maingameloop(canvas c){     m.reset();     m.postrotate(angle);     tmp = bitmap.createbitmap(image, 0, 0, width, height, m, true);     c.drawbitmap(tmp, 50, 50, null); } 

however, because bitmap.createbitmap creates bitmap every frame garbage collector works madly, causes low fps.

i have tried saving bitmap in array @ angles, , taking bitmap want to. however, needs lot of ram , app couldn't launch @ high screen resolutions.

if have ideas, please comment below.

some think this:

bitmap image; matrix m; . . . public yourclass(){     m = new matrix();     image = bitmap.createbitmap(image, 0, 0, width, height,); } . . . public void maingameloop(canvas c){     m.setrotate(angle, imagecenterx, imagecentery);     yourcanvas.drawbitmap(image, m, null); } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -