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 m开发者_如何学编程uch performance overhead will be caused by auto scaling hdpi images to fit normal screens?
Thanks.
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.
None. Do the scaling once at startup and keep the scaled image in memory.
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.
精彩评论