programmium

From Isham Mohamed


Mipmapping for drawables in Android 4.3

Android 4.3 is an update to the Jelly Bean release that offers new features for users and app developers. This document provides an introduction to the most notable new APIs.

As an app developer, you should download the Android 4.3 system image and SDK platform from the SDK Manager as soon as possible. If you don’t have a device running Android 4.3 on which to test your app, use the Android 4.3 system image to test your app on the Android emulator. Then build your apps against the Android 4.3 platform to begin using the latest APIs.

If you are about to develop of Android 4.3, in res folder you can see new mipmap-hdpi, mipmap-mdpi, mipmap-xhdpi, mipmap-xxhdpi, mipmap-xxxhdpi. But still some people are confused about what is this mipmaps.

Screen Shot 2014-03-19 at 4.42.11 pm

What is mipmap

Wikipedia defines this as

In 3D computer graphics, mipmaps (also MIP maps) are pre-calculated, optimized collections of images that accompany a main texture, intended to increase rendering speed and reduce aliasing artifacts. They are widely used in 3D computer games, flight simulators and other 3D imaging systems for texture filtering. Their use is known as mipmapping. The letters “MIP” in the name are an acronym of the Latin phrase multum in parvo, meaning “much in little”.[1] Since mipmaps cannot be calculated in real time, additional storage space is required to take advantage of them. They also form the basis of wavelet compression.

All Android developers face problems in Magnification of images, while magnification of images in Android, we face the texels of the image are easily visible, as they now cover many of the pixels on our display. With minification, many of the details are lost as many of the texels cannot be rendered onto the limited pixels available. To avoid this, some developers used this “mipmaps”.

How can we minify textures without introducing noise and use all of the texels? This can be done by generating a set of optimized textures at different sizes which we can then use at runtime. Since these textures are pre-generated, they can be filtered using more expensive techniques that use all of the texels, and at runtime OpenGL will select the most appropriate level based on the final size of the texture on the screen.

android-mipmap

The resulting image can have more detail, less noise, and look better overall. Although a bit more memory will be used, rendering can also be faster, as the smaller levels can be more easily kept in the GPU’s texture cache.

Let’s take a closer look at the resulting image at 1/8th of its original size, using bilinear filtering without and with mipmaps; the image has been expanded for clarity:

Untitled-1

The version using mipmaps has vastly more detail. Because of the pre-processing of the image into separate levels, all of the texels end up getting used in the final image.

Mipmaps are able to work with Android 2.2+. But with Android 4.3, Google almost foreces developers to use mipmaps with all their apps. This will dramatically Speeding up rendering times of images, Improving the quality and Reducing stress on GPU. And with this, developers can use heavy graphics and textures without any second thinking..



11 responses to “Mipmapping for drawables in Android 4.3”

  1. […] Mipmapping for drawables in Android 4.3 […]

  2. I am using Android 4.3 for a while but today when I created a new project for the first time mipmap folder created in my project.

    1. Happy to hear it Qasim 🙂

    2. could you please help me to put a image in android (mipmap image)

  3. what is the advantage of mipmap over drawable folder??can’t we put our images in drawable (hdpi,xhdpi,xxhdpi or diff density folders).

    1. Mipmaps has an advantage when it comes to rendering times of image, improved quality and less stress on GPU.

  4. […] Mipmapping for drawables in Android 4.3 […]

  5. […] Android 4.3에서 드로어 블에 대한 밉 매핑 […]

  6. […] Mipmapping for drawables in Android 4.3 […]

Leave a comment