Chris S
Chris S

Reputation: 65426

Is it easier to supply one high resolution drawable PNG asset and let Android scale this down?

I'm looking to create a background image for a viewgroup in an Android app, and I'm not sure what is best to do with the asset.

Is it easier (read:looks better on most phones) to simply supply the asset as 900x570 or there abouts and let Android scale it up and down automatically, or scale it myself in Photoshop and provide these images in the 3 drawable-ldpi, drawable-mdpi, and drawable-hdpi folders?

The space saving will be so small: around 10-20k, it makes more sense to me to simply let Android scale the images itself.

The targeted API will be 2.0 upwards, and tablets aren't being supported to begin with.

Upvotes: 5

Views: 2401

Answers (3)

Renaud
Renaud

Reputation: 8873

It's easier but has a cost in terms of performance.

If the target density is known, it'll be better to script all the needed conversion for your icons / splashscreen / images and forget about that to the next time your masters change… at no cost…

Here is an example using ImageMagick for my icons and listview eye-candies from pdf masters:

#!/bin/bash
convert -transparent white ic_padlock.pdf ic_padlock.png
convert -scale 36x36 ic_padlock.png ../../res/drawable-ldpi/ic_launcher_padlock.png
convert -scale 48x48 ic_padlock.png ../../res/drawable-mdpi/ic_launcher_padlock.png
convert -scale 72x72 ic_padlock.png ../../res/drawable-hdpi/ic_launcher_padlock.png
convert -scale 24x24 ic_padlock.png ../../res/drawable-ldpi/ic_listview_padlock.png
convert -scale 32x32 ic_padlock.png ../../res/drawable-mdpi/ic_listview_padlock.png
convert -scale 48x48 ic_padlock.png ../../res/drawable-hdpi/ic_listview_padlock.png
convert -transparent white ic_padlock_ok.pdf ic_padlock_ok.png
convert -scale 36x36 ic_padlock_ok.png ../../res/drawable-ldpi/ic_listview_padlock_ok.png
convert -scale 48x48 ic_padlock_ok.png ../../res/drawable-mdpi/ic_listview_padlock_ok.png
convert -scale 72x72 ic_padlock_ok.png ../../res/drawable-hdpi/ic_listview_padlock_ok.png

You can use convert with a density parameter for best rendering:

convert -density targetdensityxtargetdensity  -transparent white splash.pdf ../../res/drawable/splash.png

Upvotes: 1

kabuko
kabuko

Reputation: 36302

It is clearly easier from the developer standpoint to let Android scale the images for you, but it does not look better on most phones. Photoshop has better scaling algorithms than Android does in my experience.

Upvotes: 6

Optimus
Optimus

Reputation: 2776

if you only specify one copy images in any of drawable, drawable-ldpi, drawable-mdpi, and drawable-hdpi, android will by default scale it for you

however it is a good practice put different size images for performance reasons

Upvotes: 1

Related Questions