0

This link: http://www.mediafire.com/view/?hr441qalu6b6d7s

points to an image that show that my drawing of Bitmaps is taking a long time and resulting in lag in my application. How can I optimize this so as not to cause so much lag. Currently I have this as my canvas method:

    Canvas c = holder.lockCanvas();
    Paint p = new Paint();
    p.setTextSize(30);
    p.setColor(Color.BLACK);
    new handleStuff().execute("");
    //Actions End

    //Background
    Bitmap scaledBackground = Bitmap.createScaledBitmap(background, this.getWidth(), this.getHeight(), true);
    c.drawBitmap(scaledBackground, 0, 0, null);
    //Background End

My initial thoughts are that the drawing of the background every single time is what is causing that lag, but I am not sure.

Josh
  • 61
  • 9

1 Answers1

0

Put all object creation outside of the draw method (so only create the bmp/paint etc in your init/whatever) and then use them in the draw method.

This will speed up thing and reduce memory use and reduce garbage collection ... a lot.

MacD
  • 783
  • 7
  • 23