Best way to load a large number of images from URLs #9878
-
Basically I have a For You Page with a bunch of album art from a music service (CDN url). I noticed unlike UWP/WPF, What would be the best way to load a bunch of these images in parallel in an efficient way? I tried making a custom converter, downloading the image to a stream and then loading it, but this consumes massive amounts of Memory and is slow. Takes almost 5 seconds or more to load all the images. For reference, loading roughly 50 images with a size of 180x180 pretty much loads instantly (<200 ms) in WinUI/UWP/WPF. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Image.Source accepts IImage, which usually is an instance of Bitmap.
It really depends on how exactly you are downloading these images. Is it async, is it in parallel... Before I used this image subclass with some HttpClient helpers https://gist.github.com/maxkatz6/bc6e25db4323ede3b9a631cd7511cdb5 |
Beta Was this translation helpful? Give feedback.
-
Wow I did not think of making a subclass of Image because they are sealed in UWP. That sounds like a good idea, I will try that. Thank you |
Beta Was this translation helpful? Give feedback.
Image.Source accepts IImage, which usually is an instance of Bitmap.
Bitmap can be created from a stream.
It really depends on how exactly you are downloading these images. Is it async, is it in parallel...
Before I used this image subclass with some HttpClient helpers https://gist.github.com/maxkatz6/bc6e25db4323ede3b9a631cd7511cdb5
You might notice
Bitmap.DecodeToHeight
part - it is mostly needed if you have large original images that needs to be resized to a smaller size while decoding…