本文整理汇总了C#中Windows.UI.Xaml.Controls.Canvas.SaveAsPngIntoBufferAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.SaveAsPngIntoBufferAsync方法的具体用法?C# Canvas.SaveAsPngIntoBufferAsync怎么用?C# Canvas.SaveAsPngIntoBufferAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.Canvas
的用法示例。
在下文中一共展示了Canvas.SaveAsPngIntoBufferAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OrientationChanged
internal async void OrientationChanged(Canvas canvas, Image image)
{
if (this.IsReadOnly)
{
image.Height = ScreenResolution.HeightWithoutScale;
}
else
{
this.IsBusy = true;
BitmapImage attachImage = this.InitialImage;
double width = attachImage.PixelWidth, height = attachImage.PixelHeight;
if (Math.Max(attachImage.PixelWidth, attachImage.PixelHeight) > ScreenResolution.HeightWithoutScale)
{
if (attachImage.PixelWidth > attachImage.PixelHeight)
{
width = ScreenResolution.HeightWithoutScale;
height = ScreenResolution.HeightWithoutScale * ((double)attachImage.PixelHeight / attachImage.PixelWidth);
}
else
{
height = ScreenResolution.HeightWithoutScale;
width = ScreenResolution.HeightWithoutScale * ((double)attachImage.PixelWidth / attachImage.PixelHeight);
}
}
if (canvas.Children.Any())
{
this.ImageBuffer = await canvas.SaveAsPngIntoBufferAsync();
InitialImage = await ImageBuffer.AsBitmapImageAsync();
canvas.Background = this.InitialImage.AsImageBrush();
canvas.Children.Clear();
}
canvas.Width = width;
canvas.Height = height;
this.IsBusy = false;
}
}