当前位置: 首页>>代码示例>>C#>>正文


C# RenderTargetBitmap.SaveAsPng方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:gro-ove,项目名称:actools,代码行数:18,代码来源:UpgradeIconEditor_Editor.xaml.cs

示例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);
            }
        }
开发者ID:gro-ove,项目名称:actools,代码行数:27,代码来源:LiveryIconEditor.xaml.cs

示例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);
            }
开发者ID:gro-ove,项目名称:actools,代码行数:19,代码来源:SettingsDev.xaml.cs


注:本文中的System.Windows.Media.Imaging.RenderTargetBitmap.SaveAsPng方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。