本文整理汇总了C#中System.Windows.Media.Imaging.RenderTargetBitmap.SaveAsPng方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTargetBitmap.SaveAsPng方法的具体用法?C# RenderTargetBitmap.SaveAsPng怎么用?C# RenderTargetBitmap.SaveAsPng使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Imaging.RenderTargetBitmap
的用法示例。
在下文中一共展示了RenderTargetBitmap.SaveAsPng方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNewIcon
private async void CreateNewIcon() {
await Task.Delay(100);
if (Car == null) return;
ValuesStorage.Set(_key, NewIconLabel.Text);
// TODO: Save style?
var bmp = new RenderTargetBitmap(64, 64, 96, 96, PixelFormats.Pbgra32);
bmp.Render(NewIcon);
try {
bmp.SaveAsPng(Car.UpgradeIcon);
} catch (IOException ex) {
NonfatalError.Notify(AppStrings.UpgradeIcon_CannotChange, AppStrings.UpgradeIcon_CannotChange_Commentary, ex);
} catch (Exception ex) {
NonfatalError.Notify(AppStrings.UpgradeIcon_CannotChange, ex);
}
}
示例2: CreateNewIcon
private async Task CreateNewIcon() {
var size = new Size(64, 64);
Result.Measure(size);
Result.Arrange(new Rect(size));
Result.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
await Task.Delay(100);
if (Skin == null) return;
// TODO: save style?
var bmp = new RenderTargetBitmap(64, 64, 96, 96, PixelFormats.Pbgra32);
bmp.Render(Result);
if (Model.Value != @"0" && Model.Value != Skin.SkinNumber &&
ShowMessage(string.Format(AppStrings.LiveryIcon_ChangeNumber_Message, Model.Value), AppStrings.LiveryIcon_ChangeNumber_Title,
MessageBoxButton.YesNo) == MessageBoxResult.Yes) {
Skin.SkinNumber = Model.Value;
}
try {
bmp.SaveAsPng(Skin.LiveryImage);
} catch (IOException e) {
NonfatalError.Notify(AppStrings.LiveryIcon_CannotChange, AppStrings.LiveryIcon_CannotChange_Commentary, e);
} catch (Exception e) {
NonfatalError.Notify(AppStrings.LiveryIcon_CannotChange, e);
}
}
示例3: MakeCollage
private void MakeCollage(IEnumerable<string> imageFilenames, string outputFilename) {
var collage = new Grid();
foreach (var filename in imageFilenames) {
collage.Children.Add(new Image {
Source = LoadBitmapImage(filename),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
});
}
collage.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
collage.Arrange(new Rect(0d, 0d, collage.DesiredSize.Width, collage.DesiredSize.Height));
var bitmap = new RenderTargetBitmap((int)collage.DesiredSize.Width, (int)collage.DesiredSize.Height,
96, 96, PixelFormats.Default);
bitmap.Render(collage);
bitmap.SaveAsPng(outputFilename);
}