user256239
user256239

Reputation: 18027

Concern on performance overhead for image scale

My android app will work for both normal and hdpi device. I don't want to create two sets of images assets for normal and hdpi screen.

So, could I just create image assets for hdpi only, and use them for both normal and hdpi device. Of course, the hdpi images will be auto scaled to fit normal screen devices. Is it OK? How much performance overhead will be caused by auto scaling hdpi images to fit normal screens?

Thanks.

Upvotes: 3

Views: 493

Answers (3)

Dariusz Bacinski
Dariusz Bacinski

Reputation: 8730

You can generate performance statistics using android.os.Debug class

Start tracing by executing Debug.startMethodTracing() and stop it with Debug.stopMethodTracing(). File with the trace will be created on sd card. Then you can analyze it using TraceView tool.

This should answer you how big is performance overhead of image scaling in your application.

In your position I would generate hdpi set of images and add it to the project.

Upvotes: 0

Joseph Garvin
Joseph Garvin

Reputation: 21984

None. Do the scaling once at startup and keep the scaled image in memory.

Upvotes: 1

CodeFusionMobile
CodeFusionMobile

Reputation: 15130

The answer is "it depends".

If you are filling a listview of 10,000 items with images, then there will be a major performance difference.

If you are running a game engine with even fairly simple graphics, then there will be a major performance difference.

If you are making a custom button background scale, don't worry about it.

As far as simple UI's go, providing multiple resources makes it look better but doesn't really affect performance.

The real performance concern is with sprite scaling in games and other high framerate applications.

Upvotes: 4

Related Questions