Speed up loading of png files (used for textures) in Android OpenGL Game

| | August 10, 2015

My game has a few texture atlases that need to be loaded (in my XHDPI folder they total 3.49MB) and on a top-end device they don’t take that long to load, however on a low-end device they seem to take an age.

An example would be my old Samsung Galaxy Ace which uses the MDPI folder for it’s resources (total: 1.51MB), this takes 16 seconds, which I personally consider far too long.

Originally, I had a separate atlas for each sprite, so I merged the majority of my atlases into one big atlas after reading that it may speed things up.

Unfortunately, it hasn’t really made any difference to the load-speed.

This is how I’m loading my png files:

atlas = BitmapFactory.decodeResource(view.getResources(), R.drawable.atlasimage);

As the default load format is ARG_B8888, I though I’d attempt to load them in RGB565 as this is supposed to be quicker to load and render as well as take up less memory.

So I tried this:

BMFOptions = new BitmapFactory.Options();
BMFOptions.inDither=false;
BMFOptions.inPreferredConfig = Bitmap.Config.RGB_565;

atlas = BitmapFactory.decodeResource(view.getResources(), R.drawable.atlasimage, BMF Options);

Unfortunately, although this does reduce the quality of the image, it doesn’t reduce the load time and yields no noticible performance increase. Also, (and this may be expected), it doesn’t reduce the memory footprint of my app.

So my question is how can I optimise this so that my png’s are loaded quicker (rendering speed increase not being as important at the moment as load-speed).

One Response to “Speed up loading of png files (used for textures) in Android OpenGL Game”

  1. I don’t think there’s any faster way to load bitmaps.

    That’s an extremely long load time for so little data, are you sure it’s not specific to just that device? I have a game that’s loading WAY more bitmap data than that (300 files totaling around 20MB) in about the same time on an original Galaxy S.

Leave a Reply