本文整理汇总了C#中System.Windows.Media.Imaging.BitmapImage.CreateResizedNextPot方法的典型用法代码示例。如果您正苦于以下问题:C# BitmapImage.CreateResizedNextPot方法的具体用法?C# BitmapImage.CreateResizedNextPot怎么用?C# BitmapImage.CreateResizedNextPot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.BitmapImage
的用法示例。
在下文中一共展示了BitmapImage.CreateResizedNextPot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadImage_Execute
private Task<LoadImageResults> LoadImage_Execute(TargetImage targetImage)
{
var busyPickingFile = MainResources.Busy_PickingFile;
var busyOpeningImage = MainResources.Busy_OpeningImage;
var task = new Task<LoadImageResults>(() =>
{
BusyText = busyPickingFile;
var opfl = new OpenFileDialog
{
Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp",
Multiselect = false
};
var dlg = opfl.ShowDialog();
LoadImageResults results = new LoadImageResults
{
Loaded = false,
Target = targetImage
};
if (!dlg.HasValue || dlg.Value)
{
BusyText = busyOpeningImage;
try
{
using (var fs = File.OpenRead(opfl.FileName))
{
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.StreamSource = fs;
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.EndInit();
bmp.Freeze();
BitmapSource bmpSrc;
switch (targetImage)
{
case TargetImage.Bottom:
case TargetImage.Top:
case TargetImage.FileLarge:
case TargetImage.FileSmall:
case TargetImage.FolderOpen:
case TargetImage.FolderClosed:
case TargetImage.TopAlt:
bmpSrc = bmp.CreateResizedNextPot();
bmpSrc.Freeze();
break;
case TargetImage.SmallIcon:
case TargetImage.LargeIcon:
default:
bmpSrc = bmp;
break;
}
results.Loaded = true;
results.Image = bmpSrc;
}
}
catch
{
// ignored
}
}
return results;
});
task.Start();
return task;
}