有效检索缩放后的资产位图
我有一个包含许多图像的 GridView,这些图像是从资产文件夹中检索并从流中解码的。这些通常非常大(在应用程序的其他地方使用),但对于 GridView 来说,宽度只需 140dp 或最小高度为 150dp。我应该使用 BitmapFactory.Options 中的哪个选项将图像缩放到此密度/分辨率?我对许多不同的密度选项感到困惑。
I've got a GridView
of many images which are retrieved from the assets folder and decoded from streams. 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. Which of the options in BitmapFactory.Options
should I use to scale the image to this density/resolution? I'm confused by the many different density options.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了快速检索,您应该使用 inSampleSize。它会自动加载较小的位图,而无需先将完整图像加载到内存中。
For fast retrieval, you should use inSampleSize. It automatically loads a smaller bitmap without first loading the full image into memory.