代码之家  ›  专栏  ›  技术社区  ›  Raj

如何使用位图图像显示加密图像

  •  1
  • Raj  · 技术社区  · 14 年前

    我使用BitmapImage作为WPF中图像控件的源。

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

    现在,我已经加密了这个图像,并计划在创建BitmapImage实例时使用这个加密图像。我该怎么做?

    1 回复  |  直到 14 年前
        1
  •  0
  •   Raj    14 年前

    哎呀!答案很简单。我应该使用streamsource。

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