How to display a progressive JPEG as it loads from a web URL? I am trying to display a Google Maps image in a image control in WPF, but I want to keep the advantage of the image being a progressive JPG.
How to load a progressive JPG in WPF?
Image imgMap;
BitmapImage mapLoader = new BitmapImage();
mapLoader.BeginInit();
mapLoader.UriSource = new Uri(URL);
mapLoader.EndInit();
imgMap.Source = mapLoader;
Currently, I make do with this. It will only shows the image after it loads completely. I want to show it progressively.
A very basic sample. Im sure there are room for optimizations, and you can do a separate class from it that can handle numerous request, but at least its working, and you can shape it for your needs. Also note that this sample creates an image every time that we report a progress, you should avoid it! Do an image about every 5% or so to avoid a big overhead.
Xaml:
Code-behind: