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


C# WriteableBitmap.WritePNG方法代码示例

本文整理汇总了C#中System.Windows.Media.Imaging.WriteableBitmap.WritePNG方法的典型用法代码示例。如果您正苦于以下问题:C# WriteableBitmap.WritePNG方法的具体用法?C# WriteableBitmap.WritePNG怎么用?C# WriteableBitmap.WritePNG使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Imaging.WriteableBitmap的用法示例。


在下文中一共展示了WriteableBitmap.WritePNG方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveChangesToImage

        internal void SaveChangesToImage(InkPresenter ImageArea)
        {
            if (this.IsEditable)
            {
                WriteableBitmap wbBitmap = new WriteableBitmap(ImageArea, new TranslateTransform());
                using (var stream = new MemoryStream())
                {
                    wbBitmap.WritePNG(stream);
                    stream.Seek(0, System.IO.SeekOrigin.Begin);
                    byte[] imageBytes = new byte[stream.Length];
                    stream.Read(imageBytes, 0, (int)stream.Length);
                    this.FeedbackImage.DataBytes = imageBytes;
                }
                ImageArea.Strokes.Clear();
            }

        }
开发者ID:tapanila,项目名称:HockeySDK-Windows,代码行数:17,代码来源:FeedbackImageVM.cs

示例2: WriteTileToDisk

        protected static string WriteTileToDisk(string year, string description, int width, int height, string fontSize, Thickness margins)
        {
            Grid container = new Grid()
            {
                Width = width,
                Height = height,
                Background = (Brush)Application.Current.Resources["TransparentBrush"]
            };

            container.Children.Add(GetTextBlockToRender(description, fontSize, margins));

            // Force the container to render itself
            container.UpdateLayout();
            container.Arrange(new Rect(0, 0, width, height));

            var writeableBitmap = new WriteableBitmap(container, null);

            string fileName = SharedImagePath + "tile" + height + width + ".png";
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = new IsolatedStorageFileStream(fileName, FileMode.Create, storage))
                {
                    if (writeableBitmap.PixelHeight > 0)
                    {
                        writeableBitmap.WritePNG(stream);
                    }
                }
            }

            return fileName;
        }
开发者ID:camradal,项目名称:TodayILearned,代码行数:31,代码来源:LiveTile.cs

示例3: ShowPhotoResult

 internal async Task ShowPhotoResult(PhotoResult result)
 {
     var imageVM = new FeedbackImageVM(this.ParentVM);
     imageVM.IsEditable = true;
     byte[] imageBytes = null;
     if (Path.GetExtension(result.OriginalFileName).ToLower().EndsWith("jpg"))
     {
         BitmapImage img = new BitmapImage();
         img.SetSource(result.ChosenPhoto);
         var wbBitmap = new WriteableBitmap(img);
         using (var stream = new MemoryStream())
         {
             wbBitmap.WritePNG(stream);
             stream.Seek(0, System.IO.SeekOrigin.Begin);
             imageBytes = new byte[stream.Length];
             stream.Read(imageBytes, 0, (int)stream.Length);
         }
     }
     else //png
     {
         imageBytes = new byte[result.ChosenPhoto.Length];
         await result.ChosenPhoto.ReadAsync(imageBytes, 0, (int)result.ChosenPhoto.Length);
     }
     imageVM.FeedbackImage = new FeedbackAttachment(Path.GetFileName(result.OriginalFileName), imageBytes, null);
     Attachments.Add(imageVM);
     this.ParentVM.SwitchToImageEditor(imageVM);
 }
开发者ID:tapanila,项目名称:HockeySDK-Windows,代码行数:27,代码来源:FeedbackMessageFormVM.cs

示例4: PinButton_Click

        private void PinButton_Click(object sender, EventArgs e)
        {
            if (id == null) {
                id = DateTime.Now.Ticks.ToString();
            }

            // save sticky
            settings[id] = Sticky;

            WriteableBitmap front = new WriteableBitmap(TilePreview, null);
            CompensateForRender(front.Pixels);
            string frontFilename = GetTileFilename(id);

            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
                using (IsolatedStorageFileStream fs = isf.CreateFile(frontFilename)) {
                    front.WritePNG(fs);
                }
            }

            StandardTileData tile = new StandardTileData {
                BackgroundImage = new Uri("isostore:/" + frontFilename),
                BackBackgroundImage = new Uri("IDontExist", UriKind.Relative), // UGLY HACK
                BackContent = string.Empty,
                BackTitle = string.Empty
            };

            if (EnableBack.IsChecked.GetValueOrDefault()) {
                FlurryWP7SDK.Api.LogEvent("Enabling tile");

                WriteableBitmap back = new WriteableBitmap(BackTilePreview, null);
                CompensateForRender(back.Pixels);
                string backFilename = GetTileFilename(id, true);

                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
                    using (IsolatedStorageFileStream fs = isf.CreateFile(backFilename)) {
                        back.WritePNG(fs);
                    }
                }

                tile.BackBackgroundImage = new Uri("isostore:/" + backFilename);
            }

            var shelltile = GetTile(id);

            if (shelltile != null) {
                FlurryWP7SDK.Api.LogEvent("Updated existing tile");

                shelltile.Update(tile);
                Focus();
                MessageBox.Show("Your updated tile should be in your start screen.", "Tile updated", MessageBoxButton.OK);
            } else {
                FlurryWP7SDK.Api.LogEvent("Pinned new tile");

                ShellTile.Create(GetTileUri(id), tile);
            }
        }
开发者ID:kudresov,项目名称:StickyTiles,代码行数:56,代码来源:MainPage.xaml.cs


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