Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Rendering Baseline / Progressive JPEG Image in WPF application like Web Browser

$
0
0

I typically have large jpg file to show on a WPF application. Typically what I do is to create BitmapImage like this

var result = new BitmapImage();
result.BeginInit();
result.UriSource = new Uri("http://abc.com/cde.jpg");
result.DecodePixelWidth = thumbnailSize;
result.EndInit();

Then I bind the result BitmapImage to Image.Source. What I found is that the image is only shown on WPF application when it is fully retrieved by the WPF application. 

I know if I am setting BitmapCacheOption, the picture will be retrieved earlier then binding to happen.

result.CacheOption = BitmapCacheOption.OnLoad;

What I really wish to happen is a rendering behavior like Browser do. e.g. Baseline jpeg, the picture is showing from top down and left to right; Progressive jpeg, Full size and gradually becoming clear. 

I tried a couple of workaround by generating BitmapImage in the middle of picture downloading process (similar to what suggested here). But that creates a big memory overhead and doesn't work well with images large in size. 

I believe the ultimate solution will be something to do in decoding image stream and draw on the BitmapSource at the end. I couldn't find a control in WPF supporting this feature. Appreciate if anyone can provide any hint here. 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>