1

Main Questions:

1. Is resizing the image most likely the reason my app is slowing down?

2. Best way to deal with multiple screens when creating a game with a lot of images / big map?

3. Any suggestions or tips?

This is not so much a my code problem as it is an idea problem.

I have not tested it yet, but I am almost certain the reason for my application being slow is resizing my images. What I do is make a blank bitmap at 480x800 and draw on it. Then resize it as need be. Here is my resize method...

What can I do to either make this faster or solve my problem of dealing with multiple screens?

private Bitmap scaleImage(Bitmap picture) {
    Log.i("First Bitmap", "Size: " + picture.getWidth() + ", " + picture.getHeight());
    Matrix matrix = new Matrix();
    matrix.postScale(this.game.getScaleX(), this.game.getScaleY());
    Bitmap resizedPicture = Bitmap.createBitmap(picture, 0, 0, picture.getWidth(), picture.getHeight(), matrix, true);
    return resizedPicture;
}

BTW I am designing a game, so keep it in mind that I can't just scale everything ahead of time or otherwise the images would not go where I need them. I was thinking however that maybe you could do all your calculations related to image size, but wouldn't that be a problem?

I have read around a lot, but there was not much. I did find this link useful. Maybe someone could explain things better so that I can solve this problem and get on with my game/app!!! :)

Link to "this link": http://developer.android.com/guide/practices/screens_support.html

Zeveso
  • 1,274
  • 3
  • 21
  • 41
  • 1
    To the best of my knowledge re-sizing bitmaps do take up memory and CPU which may cause lag, maybe you can make an algorithm to construct the image based on the size of the image you want instead of constructing the image and then re-sizing as this can take up valuable time – FabianCook Feb 10 '12 at 02:12

0 Answers0