本文整理汇总了C#中System.Windows.Media.Imaging.BitmapImage.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# BitmapImage.GetHashCode方法的具体用法?C# BitmapImage.GetHashCode怎么用?C# BitmapImage.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.BitmapImage
的用法示例。
在下文中一共展示了BitmapImage.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitCache
internal static void InitCache()
{
var files = Directory.EnumerateFiles(Path.Combine(Global.CurrentDir, Global.CacheDir));
foreach (string filename in files)
{
FileInfo fileInfo = new FileInfo(filename);
Uri localFileUri = new Uri(filename);
BitmapImage image = new BitmapImage(localFileUri) { CacheOption = BitmapCacheOption.OnLoad};
images.Add(image.GetHashCode(), new CacheNode<Uri>((int)fileInfo.Length, localFileUri));
}
}
示例2: LoadBitmapFromIsoAsync
public static void LoadBitmapFromIsoAsync(
string path,
Action<BitmapImage> callback)
{
ThreadUtil.Execute(() =>
{
byte[] raw = StorageIo.ReadBinaryFile(path);
if (null == raw)
{
callback(null);
return;
}
var stm = new MemoryStream();
stm.Write(raw, 0, raw.Length);
stm.Seek(0, SeekOrigin.Begin);
ThreadUtil.UiCall(() =>
{
var img = new BitmapImage
{
CreateOptions = BitmapCreateOptions.BackgroundCreation
};
img.ImageOpened += (x, xe) =>
{
callback(img);
_asyncbmpholder.Remove(img.GetHashCode());
};
img.ImageFailed += (x, xe) =>
{
callback(null);
_asyncbmpholder.Remove(img.GetHashCode());
};
lock (_asyncbmpholder)
{
_asyncbmpholder.Add(img.GetHashCode(), img);
}
img.SetSource(stm);
});
});
}