I have a MemoryStream of 10K which was created from a bitmap of 2MB and compressed using JPEG. Since MemoryStream can’t directly be placed in System.Windows.Controls.Image for the GUI, I am using the following intermediate code to convert this back to BitmapImage and eventually System.Windows.Controls.Image.
System.Windows.Controls.Image image = new System.Windows.Controls.Image();
BitmapImage imageSource = new BitmapImage();
s.SlideInformation.Thumbnail.Seek(0, SeekOrigin.Begin);
imageSource.BeginInit();
imageSource.CacheOption = BitmapCacheOption.OnDemand;
imageSource.CreateOptions = BitmapCreateOptions.DelayCreation;
imageSource.StreamSource = s.SlideInformation.Thumbnail;
imageSource.EndInit();
imageSource.Freeze();
image.Source = imageSource;
ret = image.Source;
My question is, when I store this in BitmapImage, the memory allocation is taking around 2MB. Is this expected? Is there any way to reduce the memory?
I have around 300 thumbnails and this converstion takes around 600MB, which is very high.
Appreciate your help!