Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是想知道最好的使用方法是BitmapFactory什么?我对解码流和解码源感到困惑。在这两个上哪个是最好用的?我在这里看到了一些使用位图解码器资源的代码和许多 android 程序员和开发人员的一些解码流,这是最好的使用方式吗?
BitmapFactory
没有真正的“最佳方式”来使用 BitmapFactory。它提供了对情境有益的实用程序。
如果您从 Web 拉取位图,您可能有一个输入流提供位图数据。或者,如果磁盘上有图像,则可以打开文件系统的 InputStream。无论哪种情况,您都可能需要使用 decodeStream 调用。
您可以使用 decodeResource 从您的 res 文件夹之一解码位图,例如 drawable 文件夹或 raw 文件夹,这有时也很有用。