简体   繁体   English

高效检索缩放后的资产位图

[英]Efficient retrieval of scaled asset bitmaps

I've got a GridView of many images which are retrieved from the assets folder and decoded from streams. 我有一个GridView ,其中包含许多图像,这些图像从资产文件夹中检索并从流中解码。 These are typically quite large (to be used elsewhere in the app), but for the GridView need to only be 140dp wide or have a minimum height of 150dp. 这些通常很大(可以在应用程序的其他地方使用),但是对于GridView,宽度仅为140dp或最小高度为150dp。 Which of the options in BitmapFactory.Options should I use to scale the image to this density/resolution? 我应该使用BitmapFactory.Options哪个选项将图像缩放到此密度/分辨率? I'm confused by the many different density options. 我对许多不同的密度选项感到困惑。

For fast retrieval, you should use inSampleSize . 为了快速检索,您应该使用inSampleSize It automatically loads a smaller bitmap without first loading the full image into memory. 它会自动加载较小的位图,而无需先将完整图像加载到内存中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM