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

发布于 2024-11-29 02:28:32 字数 176 浏览 2 评论 0原文

我有一个包含许多图像的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

李不 2024-12-06 02:28:32

为了快速检索,您应该使用 inSampleSize。它会自动加载较小的位图,而无需先将完整图像加载到内存中。

For fast retrieval, you should use inSampleSize. It automatically loads a smaller bitmap without first loading the full image into memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文