當前位置: 首頁>>代碼示例>>C#>>正文


C# BitmapImage.GetAsFrozen方法代碼示例

本文整理匯總了C#中System.Windows.Media.Imaging.BitmapImage.GetAsFrozen方法的典型用法代碼示例。如果您正苦於以下問題:C# BitmapImage.GetAsFrozen方法的具體用法?C# BitmapImage.GetAsFrozen怎麽用?C# BitmapImage.GetAsFrozen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Media.Imaging.BitmapImage的用法示例。


在下文中一共展示了BitmapImage.GetAsFrozen方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BeginSaveImage

		public void BeginSaveImage(TileIndex id, BitmapImage image)
		{
			string imagePath = GetImagePath(id);

			bool errorWhileDeleting = false;

			bool containsOld = Contains(id);
			if (containsOld && saveOption == SaveOption.ForceUpdate)
				try
				{
					File.Delete(imagePath);
				}
				catch (IOException exc)
				{
					// todo возможно, тут добавить файл в очередь на удаление или перезапись новым содержимым
					// когда он перестанет быть блокированным
					Debug.WriteLine(String.Format("{0} - error while deleting tile {1}: {2}", Name, id, exc.Message));
					errorWhileDeleting = true;
				}

			bool shouldSave = saveOption == SaveOption.ForceUpdate && !errorWhileDeleting ||
				saveOption == SaveOption.PreserveOld && !containsOld;
			if (shouldSave)
			{
				Debug.WriteLine("Began to save id = " + id);

				Statistics.IntValues["ImagesSaved"]++;

				ImageSaver saver = ScreenshotHelper.SaveBitmapToFile;
				saver.BeginInvoke((BitmapImage)image.GetAsFrozen(), imagePath, null, null);
			}
		}
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:32,代碼來源:WriteableFileSystemTileServer.cs

示例2: BeginLoadImageAsync

		protected BitmapImage BeginLoadImageAsync(TileIndex id)
		{
			//Debug.Assert(Contains(id));

			string imagePath = GetImagePath(id);

			BitmapImage bmp = new BitmapImage();
			bmp.BeginInit();
			bmp.CacheOption = BitmapCacheOption.OnLoad;
			bmp.UriSource = new Uri(imagePath);
			try
			{
				bmp.EndInit();
			}
			catch (NotSupportedException exc)
			{
				Debug.WriteLine(String.Format("{0}: failed id = {1}. Exc = \"{2}\"", GetCustomName(), id, exc.Message));

				Action corruptedFileDeleteAction = () =>
				{
					try
					{
						File.Delete(imagePath);
					}
					catch (Exception e)
					{
						Debug.WriteLine("Exception while deleting corrupted image file \"" + imagePath + "\": " + e.Message);
					}
				};

				lock (fileDeleteActions)
				{
					fileDeleteActions.Add(corruptedFileDeleteAction);
					if (!corruptedFilesDeleteTimer.IsEnabled)
						corruptedFilesDeleteTimer.Start();
				}

				return null;
			}
			catch (FileNotFoundException exc)
			{
				Debug.WriteLine(String.Format("{0}: failed id = {1}. Exc = \"{2}\"", GetCustomName(), id, exc.Message));
				return null;
			}

			return (BitmapImage)bmp.GetAsFrozen();
		}
開發者ID:elsiete,項目名稱:DynamicDataDisplay,代碼行數:47,代碼來源:AsyncFileSystemServer.cs


注:本文中的System.Windows.Media.Imaging.BitmapImage.GetAsFrozen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。