1

I was researching a little bit on mipmap to learn more about it. However, I just ended up confusing myself even more.

In this post: Mipmaps vs. drawable folders

The reason they use a different density is that some launchers actually display the icons larger than they were intended. Because of this, they use the next size up.

Hence, I got the idea that with larger icons mipmap will use a higher density(scaling up).

But then in this post: Mipmap drawables for icons

However some launchers (shipped with some devices, or available on the Play Store) use larger icon sizes than the standard 48dp. Launchers use getDrawableForDensity and scale down if needed, rather than up, so the icons are high quality. For example on an hdpi tablet the launcher might load the xhdpi icon.

I concluded that for larger icons, mipmap will scale down the icons to provide higher quality.

And finally in this post:Mipmap drawables for icons by @Sergej:

What Android will do is, it will try to pick up the image from a higher density bucket instead of scaling it up. This will increase sharpness (quality) of the image.

Mipmap will use a higher density instead of scaling up for larger icons.

What is really going on? Thanks.

Update: Also, in the second post Mipmap drawables for icons by @Kazuaki, I don't understand this

Different home screen launcher apps on different devices show app launcher icons at various resolutions. When app resource optimization techniques remove resources for unused screen densities, launcher icons can wind up looking fuzzy because the launcher app has to upscale a lower-resolution icon for display. To avoid these display issues, apps should use the mipmap/ resource folders for launcher icons. The Android system preserves these resources regardless of density stripping, and ensures that launcher apps can pick icons with the best resolution for display.

Even if unused screen densities are stripped, why would the launcher app have to switch to a lower resolution? The current resolution(whatever resolution it's using), isn't unused, meaning, it wouldn't be stripped and the launcher icon wouldn't have to switch resolutions.

How does this work? Thanks.

CodingChap
  • 1,088
  • 2
  • 10
  • 23

2 Answers2

1

I think your confusion about @Kazuaki quote is the now deleted documentation, replaced by: https://developer.android.com/training/multiscreen/screendensities#mipmap

Like all other bitmap assets, you need to provide density-specific versions of you app icon. However, some app launchers display your app icon as much as 25% larger than what's called for by the device's density bucket.

For example, if a device's density bucket is xxhdpi and the largest app icon you provide is in drawable-xxhdpi, the launcher app scales up this icon, and that makes it appear less crisp. So you should provide an even higher density launcher icon in the mipmap-xxxhdpi directory. Now the launcher can use the xxxhdpi asset instead.

The mipmap directories provide that "do not remove when trying to make a smaller APK".

Morrison Chang
  • 11,691
  • 3
  • 41
  • 77
  • So basically, in simple terms, mipmap just allows you to use higher densities for larger icons? – CodingChap May 20 '21 at 04:26
  • Correct. The mipmap icons are the way for the launcher app to use bigger icons. In app you have the screen density buckets or vector drawables (SVG subset). – Morrison Chang May 20 '21 at 04:40
  • Got it. Thank you for the clarification! – CodingChap May 20 '21 at 04:41
  • Hi, in the quote by @Sergej "What Android will do is, it will try to pick up the image from a higher density bucket instead of scaling it up. This will increase sharpness (quality) of the image"; is it true that they won't make the icon larger and instead pick a higher density? In my understanding, I thought it would scale the icon as necessary and then pick it from the respective density bucket depending on the size. Thanks. – CodingChap May 20 '21 at 15:13
  • Launcher icons are specified in `dp` which at higher density means more pixels. How the launcher app decides what to use to make the bigger icon is developer dependent, but it is easier to make something visually pleasing to show fewer pixels if your source has more. There are a variety of open-source launcher/home screen apps should you wish to delve into specifics. – Morrison Chang May 20 '21 at 18:08
  • Hi, thanks. I'm still confused though. Will it not make the icon bigger(if we were to program an expand animation as the developer, for example), but instead use a higher density? My understanding is that it will increase the size, and also use a higher density, but now I'm unsure. How does this work? Thanks. – CodingChap May 20 '21 at 18:35
  • From who's perspective are you asking? The launcher app wants as many sizes as possible so that it can show nice rather than blocky target app icons if launcher app wants to show bigger target icons (or do other visual tricks like animation). Always keep in mind that device screen size/resolution/density doesn't change. Target app just needs to have all mipmap sizes rather than use density buckets which might get removed as more pixels/files = bigger APK = poor user data usage. – Morrison Chang May 20 '21 at 18:59
  • Hi, so my question is in this post: https://stackoverflow.com/questions/23935810/mipmap-drawables-for-icons by @Sergej where he says, "What Android will do is, it will try to pick up the image from a higher density bucket **instead** of scaling it up. This will increase sharpness (quality) of the image." I don't understand why **instead** of scaling it up to a larger size, it will use a higher density. In the post, he's talking about the developers perspective for the animation, but Android's perspective for the sharpness of the image. Thanks. – CodingChap May 20 '21 at 19:47
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/232664/discussion-between-morrison-chang-and-codingchap). – Morrison Chang May 20 '21 at 20:08
0

In my understanding, mipmaping is principally for scaling-down.

In OpenGL, you can set texture filtering modes. One for scaling-down (minification), another for scaling-up (magnification) (cf. An Introduction to Texture Filtering).

Scaling-down (GL_TEXTURE_MIN_FILTER):

  • GL_NEAREST
  • GL_LINEAR
  • GL_NEAREST_MIPMAP_NEAREST
  • GL_NEAREST_MIPMAP_LINEAR
  • GL_LINEAR_MIPMAP_NEAREST
  • GL_LINEAR_MIPMAP_LINEAR

Scaling-up (GL_TEXTURE_MAG_FILTER):

  • GL_NEAREST
  • GL_LINEAR

You notice that there are no options of mipmap for scaling-up, but those are for scaling-down.

So, in my understanding, if scaling-up/down is needed, the nearest higher density texture is chosen to scale-down. Only when the current magnification is higher than the highest density texture, scaling-up is done based on the highest one.

hata
  • 11,633
  • 6
  • 46
  • 69
  • Hi, thank you for the response. Please see the update in the question. I'm really confused on that. Thanks. – CodingChap May 20 '21 at 00:39