本文整理汇总了C#中System.Windows.Media.ImageSource.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# ImageSource.Freeze方法的具体用法?C# ImageSource.Freeze怎么用?C# ImageSource.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.ImageSource
的用法示例。
在下文中一共展示了ImageSource.Freeze方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShadowWindow
static ShadowWindow()
{
ActiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottom.png"));
ActiveBottomImage.Freeze();
ActiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomLeft.png"));
ActiveBottomLeftImage.Freeze();
ActiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomRight.png"));
ActiveBottomRightImage.Freeze();
ActiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveLeft.png"));
ActiveLeftImage.Freeze();
ActiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveRight.png"));
ActiveRightImage.Freeze();
ActiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTop.png"));
ActiveTopImage.Freeze();
ActiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopLeft.png"));
ActiveTopLeftImage.Freeze();
ActiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopRight.png"));
ActiveTopRightImage.Freeze();
InactiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottom.png"));
InactiveBottomImage.Freeze();
InactiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomLeft.png"));
InactiveBottomLeftImage.Freeze();
InactiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomRight.png"));
InactiveBottomRightImage.Freeze();
InactiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveLeft.png"));
InactiveLeftImage.Freeze();
InactiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveRight.png"));
InactiveRightImage.Freeze();
InactiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTop.png"));
InactiveTopImage.Freeze();
InactiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopLeft.png"));
InactiveTopLeftImage.Freeze();
InactiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopRight.png"));
InactiveTopRightImage.Freeze();
}
示例2: ProcessInfo
public ProcessInfo(Process rpProcess)
{
ID = rpProcess.Id;
Name = rpProcess.ProcessName;
var rInfo = rpProcess.MainModule.FileVersionInfo;
if (rInfo.FileDescription != Name)
Description = rInfo.FileDescription;
NativeStructs.SHFILEINFO rFileInfo;
NativeMethods.Shell32.SHGetFileInfoW(rInfo.FileName, 0, out rFileInfo, Marshal.SizeOf(typeof(NativeStructs.SHFILEINFO)), NativeEnums.SHGFI.SHGFI_ICON);
Icon = Imaging.CreateBitmapSourceFromHIcon(rFileInfo.hIcon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
Icon.Freeze();
if (rFileInfo.hIcon != IntPtr.Zero)
NativeMethods.User32.DestroyIcon(rFileInfo.hIcon);
}
示例3: Load
public void Load()
{
try
{
_asyncSource = new BitmapImage(new Uri(filename));
_asyncSource.Freeze();
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("AsyncSource"));
if (loaded != null)
loaded();
});
}
catch (Exception ex)
{
Logger.Error("An error has occured while trying to create an AsyncThumbnailImage. Filename = {0} Exception = {1}", LogSource.BackgroundTask, filename, ex);
}
}
示例4: Load
public void Load()
{
try
{
// If we have a loading function, use that to get the url we want to load
if (loading != null)
this.url = loading();
// We explicitly use the WebClient here because we need access to the system-wide browser cache and cookies collection
var client = new WebClient { CachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable) };
var stream = new MemoryStream();
using (var istream = client.OpenRead(url))
{
// Read stream into our own byte buffer on the background thread
istream.CopyTo(stream);
stream.Seek(0, SeekOrigin.Begin);
}
var headers = client.ResponseHeaders;
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
try
{
// Create imagesource on the foreground thread
string extension = Path.GetExtension(url).ToLower();
BitmapDecoder decoder = null;
if (extension == ".gif")
decoder = new GifBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else if (extension == ".png")
decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else if (extension == ".jpg" || extension == ".jpeg")
decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else if (extension == ".bmp")
decoder = new BmpBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else
{
// We are not sure what extension we are looking at, lets see if there is a content-type available
if (headers["Content-Type"] != null)
{
var type = headers["Content-Type"];
if (type.IndexOf("gif", StringComparison.InvariantCultureIgnoreCase) > -1)
decoder = new GifBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else if (type.IndexOf("png", StringComparison.InvariantCultureIgnoreCase) > -1)
decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else if (type.IndexOf("jpg", StringComparison.InvariantCultureIgnoreCase) > -1 || type.IndexOf("jpeg", StringComparison.InvariantCultureIgnoreCase) > -1)
decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
else if (type.IndexOf("bmp", StringComparison.InvariantCultureIgnoreCase) > -1)
decoder = new BmpBitmapDecoder(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
}
}
if (decoder == null)
{
Logger.Error("Unable to determine type of image to decode. url = {0}", LogSource.BackgroundTask, url);
return;
}
_asyncSource = decoder.Frames[0];
_asyncSource.Freeze();
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("AsyncSource"));
if (loaded != null)
loaded();
}
catch (Exception ex)
{
Logger.Error("An error has occured while trying to download an AsyncHttpImage. Url = {0} Exception = {1}", LogSource.BackgroundTask, url, ex);
}
finally
{
stream.Dispose();
}
});
}
catch (Exception ex)
{
Logger.Error("An error has occured while trying to download an AsyncHttpImage. Url = {0} Exception = {1}", LogSource.BackgroundTask, url, ex);
}
}
示例5: ExtractSmall
/// <summary>
/// Extracts 16*16 icon when ImageContainer is constructed with PowerItem data
/// </summary>
public void ExtractSmall()
{
if (_smallBitmap != null)
return;
var smallIconHandle = GetUnmanagedIcon(API.Shgfi.SMALLICON);
if (smallIconHandle != IntPtr.Zero)
{
SmallBitmap = ExtractInternal(smallIconHandle);
SmallBitmap.Freeze();
Util.PostBackgroundIconDestroy(smallIconHandle);
}
#if DEBUG
else
{
Log.Raw("FAILED with code " + Marshal.GetLastWin32Error(), _initialObject);
}
#endif
_smallExtracted = true;
}