本文整理匯總了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);
});
});
}