Mipmap 是放大还是缩小?

Does Mipmap scale up or scale down?

我正在对 mipmap 进行一些研究以了解更多信息。然而,我只是把自己弄得更糊涂了。

在此post中:

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.

因此,我认为对于较大的图标,mipmap 将使用更高的密度(按比例放大)。

但是在这个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.

我得出的结论是,对于较大的图标,mipmap 会缩小图标以提供更高的质量。

最后在这个 post:Mipmap drawables for icons @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 将使用更高的密度,而不是为更大的图标放大。

到底是怎么回事?谢谢。

更新: 另外,在 @Kazuaki 的第二个 post 图标的 Mipmap 可绘制对象中,我不明白这个

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.

即使去除了未使用的屏幕密度,为什么启动器应用程序必须切换到较低的分辨率?当前分辨率(无论它使用的是什么分辨率)并非未使用,这意味着它不会被删除,启动器图标也不必切换分辨率。

这是如何工作的?谢谢。

在我的理解中,mipmaping 主要是为了按比例缩小。

在 OpenGL 中,您可以设置纹理过滤模式。一个用于缩小(缩小),另一个用于放大(放大)(cf. An Introduction to Texture Filtering)。

缩减(GL_TEXTURE_MIN_FILTER):

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

扩大规模(GL_TEXTURE_MAG_FILTER):

  • GL_NEAREST
  • GL_LINEAR

您注意到 mipmap 没有用于放大的选项,但有用于缩小的选项。

所以,以我的理解,如果需要scaling-up/down,则选择最近的较高密度纹理进行缩小。只有当当前放大倍数高于最高密度纹理时,才按最高密度放大。

我认为你对@Kazuaki 引用的困惑是现在删除的文档,取而代之的是: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.

mipmap 目录规定“在尝试制作较小的 APK 时不要删除”。