本文整理汇总了C#中IImageProvider.GetInfoAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IImageProvider.GetInfoAsync方法的具体用法?C# IImageProvider.GetInfoAsync怎么用?C# IImageProvider.GetInfoAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImageProvider
的用法示例。
在下文中一共展示了IImageProvider.GetInfoAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSize
private static Size GetSize(IImageProvider provider)
{
if (provider is IImageSize)
{
return (provider as IImageSize).Size;
}
return provider.GetInfoAsync().AsTask().Result.ImageSize;
}
示例2: CreateFromTileSource
/// <summary>
/// Constructs an image source of a given size by repeating a given tile.
/// </summary>
/// <param name="requestedSize">The requested dimensions of a source.</param>
/// <param name="tileSource">The IImageProvider that will be repeated.</param>
/// <remarks>This is a convinience method that will look up the tileSource size before calling the public constructor. A rendering operation may be needed to compute the size, depending on the source. This may lead to reduced performance.</remarks>
public static async Task<RepeatedTileImageSource> CreateFromTileSource(Size requestedSize, IImageProvider tileSource)
{
var tileSize = (await tileSource.GetInfoAsync()).ImageSize;
return new RepeatedTileImageSource(requestedSize, tileSource, tileSize);
}
示例3: LoadPhotoInternalAsync
private async Task<SoftwareBitmap> LoadPhotoInternalAsync(IImageProvider unnormalizedSource)
{
DisposableHelper.TryDisposeAndSetToNull(ref m_source);
var info = await unnormalizedSource.GetInfoAsync().AsTask().ConfigureAwait(false);
var unnormalizedSourceSize = info.ImageSize;
if ((uint)unnormalizedSourceSize.Width == 0 || (uint)unnormalizedSourceSize.Height == 0)
{
throw new ArgumentException("Image source appears to be zero sized.");
}
// Normalize source bitmap to ~5 MP
m_sourceSize = NormalizeSourceSize(unnormalizedSourceSize);
using(var bitmapRenderer = new SoftwareBitmapRenderer(unnormalizedSource))
{
bitmapRenderer.Size = m_sourceSize;
bitmapRenderer.OutputOption = OutputOption.PreserveAspectRatio;
bitmapRenderer.RenderOptions = RenderOptions.Cpu;
var normalizedSourceBitmap = await bitmapRenderer.RenderAsync().AsTask().ConfigureAwait(false);
m_source = new SoftwareBitmapImageSource(normalizedSourceBitmap);
}
using(var bitmapRenderer = new SoftwareBitmapRenderer(m_source))
{
bitmapRenderer.Size = PreviewSize;
bitmapRenderer.OutputOption = OutputOption.PreserveAspectRatio;
bitmapRenderer.RenderOptions = RenderOptions.Cpu;
return await bitmapRenderer.RenderAsync().AsTask().ConfigureAwait(false);
}
}
示例4: GetSize
private static Size GetSize(IImageProvider imageProvider)
{
return imageProvider.GetInfoAsync().AsTask().Result.ImageSize;
}