本文整理汇总了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();
}
//.........这里部分代码省略.........