本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.CentreCrop方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.CentreCrop方法的具体用法?C# WriteableBitmap.CentreCrop怎么用?C# WriteableBitmap.CentreCrop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.WriteableBitmap
的用法示例。
在下文中一共展示了WriteableBitmap.CentreCrop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateBackContentImages
public async Task UpdateBackContentImages()
{
var items = await GetCollectionItems(1, ImageType.Backdrop);
if (items == null || items.Items.IsNullOrEmpty())
{
return;
}
var item = items.Items.FirstOrDefault();
var apiClient = _connectionManager.GetApiClient(App.ServerInfo.Id);
var wideUrl = apiClient.GetImageUrl(item, new ImageOptions
{
ImageType = ImageType.Backdrop,
MaxWidth = 691,
Quality = Constants.ImageQuality,
EnableImageEnhancers = false
});
try
{
var client = CreateClient();
var response = await client.GetAsync(wideUrl);
var stream = await response.Content.ReadAsStreamAsync();
var imageSource = new BitmapImage();
imageSource.SetSource(stream);
var writeableImage = new WriteableBitmap(imageSource);
await SaveTheImage(writeableImage, WideTileBackUrl);
var mediumWriteableImage = writeableImage.CentreCrop(336, 336);
await SaveTheImage(mediumWriteableImage, MediumTileBackUrl);
}
catch (HttpException ex)
{
_logger.ErrorException("UpdateBackContentImages()", ex);
}
catch (Exception ex)
{
_logger.ErrorException("UpdateBackContentImages()", ex);
}
}