Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What kind of image formats should I use in an Android application?

I'm writing a game for Android and I was wondering what kind of images should I use for the in game graphics.

I told the customer to create the artwork in the highest possible (and reasonable) resolution and I will scale it down but I have been told lately that SVG would be better than plain PNG for example since there are a lot of resolutions used by Android devices and the images have to be scaled. Most of the graphics will be stationary backgorunds or objects but there will be some animations. I will use AnimationDrawable for this.

Is there some general guideline for graphical file formats (I checked out android developer site but didn't find anything) or just go with whatever I have at the moment?

like image 785
Adam Arold Avatar asked Nov 23 '12 13:11

Adam Arold


2 Answers

I have been told lately that SVG would be better than plain PNG for example

Android does not support SVG natively. There are third-party libraries that support SVG, such as this one.

since there are a lot of resolutions used by Android devices and the images have to be scaled

If that is literally what your graphic designer told you, you need to hire a different graphic designer. Quickly.

Resolution is typically meaningless. What matters is screen size and, more importantly for graphics, screen density. Android supports multiple versions of an image for different densities, and can also resample images from one density into another, so you can "dial in" how many densities you wish to support directly. Here is a blog post from yesterday regarding screen density, and there is plenty of material in the Android documentation on this as well.

Now, your graphic designer might use SVG "internally" and generate density-scaled PNG files for your use -- that is perfectly reasonable.

like image 52
CommonsWare Avatar answered Oct 09 '22 19:10

CommonsWare


Is there some general guideline for graphical file formats

Yes, here. It says

Android supports bitmap files in a three formats: .png (preferred), .jpg (acceptable), .gif (discouraged).

There is no native support for SVG drawables but there are libraries that support SVG

See SVG support on Android

You would typically convert SVG images to pixel images for each density. Android also defines some standard sizes for icons like Menu icons

Having the sources for the images you use as SVG is not a bad idea. SVG and other vector based graphics usually scale better to different sizes than pixel graphics. Especially if you need to enlarge an image (for example for the hi-res icons used in the Play store).

Also be careful with AnimationDrawable, it is not meant to be used for fullscreen animations. Just small animated icons and such.

like image 20
zapl Avatar answered Oct 09 '22 18:10

zapl