tags:

views:

43

answers:

1

I'm using BitmapImage as Source to an Image control in WPF.

BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bi.UriSource = new Uri(strFilePath);
bi.EndInit();
return bi;

Now I've encrypted this image and planning to use this encrypted image when creating instance of BitmapImage. How do I do this?

A: 

Oops! Answer was pretty simple. I should have used StreamSource.

BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.CreateOptions = BitmapCreateOptions.None;
bi.StreamSource = decryptedImageStream;
bi.EndInit();
Raj