简体   繁体   English

在Android中存储和显示图像的最佳方法

[英]Best way to store and display images in Android

I am developing an application which can edit images. 我正在开发可以编辑图像的应用程序。 At the start of my program the user sees a list of folders that contain images. 在我的程序开始时,用户会看到包含图像的文件夹列表。 Instead of showing default folder icon i am showing an image from folder. 我没有显示默认文件夹图标,而是显示了文件夹中的图像。 I have database where i store path to images and information about which image is displaying in the list near the folder name. 我有一个数据库,用于存储图像的路径以及有关文件夹名称附近列表中显示的图像的信息。 Every time when my application starts it takes a lot of time to load a scaled down image into memory and then display it, especially when there are a lot of folders with images and for each i need to load its icon. 每次我的应用程序启动时,都要花大量时间将按比例缩小的图像加载到内存中,然后再显示它,尤其是当有很多包含图像的文件夹且每个我都需要加载其图标时。 I have read this article http://developer.android.com/training/displaying-bitmaps/index.html and every time when my app starts i am scaling down every image. 我已经阅读了这篇文章http://developer.android.com/training/displaying-bitmaps/index.html ,每次我的应用启动时,我都会缩小每张图像。 May be the best way in this situation is to resize (not scale down) every image and then store it in the database? 在这种情况下,最好的方法是调整每个图像的大小(而不是缩小),然后将其存储在数据库中? But i have read that this is not good. 但是我读到这不好。 So i want to ask an advice of how to do in this case? 所以我想问一下在这种情况下该怎么做的建议? And i also need an advice of how to optimize displaying images in the Android Galllery widget to make it scrolling more faster. 我还需要有关如何优化Android Galllery小部件中的图像显示以使其滚动更快的建议。 Thank you very much! 非常感谢你!

1 Never store images in database. 1切勿将图像存储在数据库中。 It is inefficient and slow. 它效率低下且速度慢。

2 There are several image loading libraries that solve the same problem. 2有几个图像加载库可以解决相同的问题。 My favorites are Picasso and Universal Image Loader 我最喜欢的是PicassoUniversal Image Loader

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

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