当前位置: 首页>>代码示例>>C#>>正文


C# ImageSource.ToString方法代码示例

本文整理汇总了C#中ImageSource.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ImageSource.ToString方法的具体用法?C# ImageSource.ToString怎么用?C# ImageSource.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageSource的用法示例。


在下文中一共展示了ImageSource.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDrawableAsync

		protected virtual async Task<WithLoadingResult<SelfDisposingBitmapDrawable>> GetDrawableAsync(string path, ImageSource source, bool isLoadingPlaceHolder, bool isPlaceholder, Stream originalStream = null)
		{
			if (IsCancelled)
				return new WithLoadingResult<SelfDisposingBitmapDrawable>(LoadingResult.Canceled);

			// First decode with inJustDecodeBounds=true to check dimensions
			var options = new BitmapFactory.Options
			{
				InJustDecodeBounds = true
			};

			Stream stream = null;
			WithLoadingResult<Stream> streamWithResult;
			if (originalStream != null)
			{
				streamWithResult = new WithLoadingResult<Stream>(originalStream, LoadingResult.Stream);
			}
			else
			{
				streamWithResult = await GetStreamAsync(path, source).ConfigureAwait(false);
			}

			if (streamWithResult.HasError)
			{
				if (streamWithResult.Result == LoadingResult.NotFound)
				{
					Logger.Error(string.Format("Not found: {0} from {1}", path, source.ToString()));
				}
				return new WithLoadingResult<SelfDisposingBitmapDrawable>(streamWithResult.Result);
			}

			stream = streamWithResult.Item;

			try
			{
				try
				{
// NOTE: CURRENTLY NOT NEEDED							
//							if (streamWithResult.Result == LoadingResult.Internet)
//							{
//								// When loading from internet stream we shouldn't block otherwise other downloads will be paused
//								BitmapFactory.DecodeStream(stream, null, options);
//							}
//							else
//							{
						lock (_decodingLock)
						{
							BitmapFactory.DecodeStream(stream, null, options);
						}
//							}

					if (!stream.CanSeek)
					{
						if (stream == originalStream)
						{
							// If we cannot seek the original stream then there's not much we can do
							return new WithLoadingResult<SelfDisposingBitmapDrawable>(LoadingResult.Failed);
						}
						else
						{
							// Assets stream can't be seeked to origin position
							stream.Dispose();
							streamWithResult = await GetStreamAsync(path, source).ConfigureAwait(false);
							if (streamWithResult.HasError)
							{
								return new WithLoadingResult<SelfDisposingBitmapDrawable>(streamWithResult.Result);
							}

							stream = streamWithResult.Item;
						}
					}
					else
					{
						stream.Seek(0, SeekOrigin.Begin);
					}
				}
				catch (Exception ex)
				{
					Logger.Error("Something wrong happened while asynchronously retrieving image size from file: " + path, ex);
					return new WithLoadingResult<SelfDisposingBitmapDrawable>(LoadingResult.Failed);
				}

				if (IsCancelled)
					return new WithLoadingResult<SelfDisposingBitmapDrawable>(LoadingResult.Canceled);

				options.InPurgeable = true;
				options.InJustDecodeBounds = false;

				if (!ImageService.Config.LoadWithTransparencyChannel || Parameters.LoadTransparencyChannel == null || !Parameters.LoadTransparencyChannel.Value)
				{
					// Same quality but no transparency channel. This allows to save 50% of memory: 1 pixel=2bytes instead of 4.
					options.InPreferredConfig = Bitmap.Config.Rgb565;
				}

				// CHECK IF BITMAP IS EXIF ROTATED
				int exifRotation = 0;
				if (source == ImageSource.Filepath)
				{
					exifRotation = path.GetExifRotationDegrees();
				}
//.........这里部分代码省略.........
开发者ID:petlack,项目名称:FFImageLoading,代码行数:101,代码来源:ImageLoaderTask.cs


注:本文中的ImageSource.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。