Possibility to cache preprocessed image on disc #314
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
As promised here #309, I've implemented the functionality and made this pull request.
I've tested this with the app I'm developing. I have a listview that is loaded and paginated from the web. When I loaded too many items, each one with its image (some of the images was repeating), the memory cache was becoming full quickly and it was starting to preprocess all the images again, when I scroll up. It was consuming much CPU and memory... and also giving the user the impression that the image was being loaded again. Now, it's putting the preprocessed image on disc cache. So, it's preprocessing the image just one time and it saved me a lot of CPU and memory. At the moment, I tested to load about 800 items in the ListView. Since some images are repeating, I think it's about 300 unique images in the ListView. When I scroll down, more items are loaded. If I scroll up until reach the top, I see all the images quickly, as if it was loaded instantly. And it's scrolling smoothly.
The way I've implemented, it's not going to break any code that uses this new version. I've included a new option called cachePreProcessedImageOnDisc in the DisplayImageOptions. I think that the user usually would use either cacheOnDisc or cachePreProcessedImageOnDisc. If both are activated, the original image will be loaded from the network to the file and then the file will be overwritten with the preprocessed image.
I hope it's useful.