Android 从API level 17 开始,引入mipmap 技术,可以提高bitmap图片渲染的速度和质量。
mipmap是目前应用最为广泛的纹理映射技术之一。Android 中的 mipmap 技术主要为了应对图片大小缩放的处理,在android应用中我们使用一个 bitmap 图片,由于应用的需要可能对这个图片进行缩放操作,为了提高缩小的速度和图片的质量,Android 通过 mipmap 技术提前对按缩小层级生成图片预先存储在内存中,这样就提高了图片渲染的速度和质量。
对于Android开发人员,图片资源放在drawable目录和mipmap目录下,在使用上没有任何区别,只需要代码调用图片资源时采用R.mipmap.imagename的形式即可。
官方介绍:
Mipmapping for drawables
Using a mipmap as the source for your bitmap or drawable is a simple way to provide a quality image and various image scales, which can be particularly useful if you expect your image to be scaled during an animation.
Android 4.2 (API level 17) added support for mipmaps in the Bitmap class—Android swaps the mip images in your Bitmap when you've supplied a mipmap source and have enabled setHasMipMap(). Now in Android 4.3, you can enable mipmaps for a BitmapDrawable object as well, by providing a mipmap asset and setting the android:mipMap attribute in a bitmap resource file or by calling hasMipMap().