{"id":1750,"date":"2013-11-05T12:43:52","date_gmt":"2013-11-05T10:43:52","guid":{"rendered":"http:\/\/mariusbancila.ro\/blog\/?p=1750"},"modified":"2013-11-05T12:43:53","modified_gmt":"2013-11-05T10:43:53","slug":"render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/","title":{"rendered":"Render the screen of a Windows Store App to a bitmap in Windows 8.1"},"content":{"rendered":"<p>In WPF, Silverlight and Windows Phone it is possible to render a visual object into a bitmap using the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.media.imaging.rendertargetbitmap(v=vs.110).aspx\">RenderTargetBitmap<\/a>. This functionality, that I find pretty basic, was not available for Windows Store applications. Fortunately, Windows 8.1 provides that functionality for Windows Store applications too, through the same <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/apps\/dn298548\">RenderTargetBitmap class<\/a>.<\/p>\n<p>There are some limitations though:<\/p>\n<ul>\n<li>it should be used in the code behind (not declared in XAML) because you have to call RenderAsync<\/li>\n<li>collapsed visual objects are not rendered (only visible ones)<\/li>\n<li>in rare circumstances the content can be lost due to the interaction with lower level systems; in this case a specific exception is triggered<\/li>\n<li>the rendered target bitmap does not automatically scale when the current DPI settings change<\/li>\n<li>the maximum rendered size of a XAML visual tree is restricted by the maximum dimensions of a DirectX texture<\/li>\n<\/ul>\n<p>Here is a demo Windows Store application that has several controls and a button that when pressed a screenshot of the area shown in red (it&#8217;s a grid) is taken. The bitmap is saved on disk, but also displayed as the source for the image control shown in the preview area.<\/p>\n<p><a href=\"http:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1751\" alt=\"wsas1\" src=\"http:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas1.png\" width=\"800\" height=\"748\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas1.png 800w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas1-300x280.png 300w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;Page&gt;\r\n    &lt;Grid Background=\"{ThemeResource ApplicationPageBackgroundThemeBrush}\" Name=\"mainGrid\"&gt;\r\n\r\n      &lt;TextBlock Text=\"Windows Store App Screenshot Demo\" Style=\"{StaticResource HeaderTextBlockStyle}\"\r\n                 Grid.Column=\"0\" Grid.ColumnSpan=\"5\" Grid.Row=\"0\"\r\n                 Margin=\"0,30,0,30\"\r\n                 TextAlignment=\"Center\" \/&gt;\r\n\r\n      &lt;Grid Name=\"controlsGrid\" Grid.Column=\"1\" Grid.ColumnSpan=\"2\" Grid.Row=\"1\" Margin=\"5,5,5,50\"&gt;\r\n      &lt;\/Grid&gt;\r\n    &lt;\/Grid&gt;\r\n&lt;\/Page&gt;<\/pre>\n<p>The handler for the <tt>Click<\/tt> button even looks like this:<\/p>\n<pre class=\"lang:c# decode:true\">async void btnScreenshot_Click(object sender, RoutedEventArgs e)\r\n{\r\n   var bitmap = await SaveScreenshotAsync(controlsGrid);\r\n\r\n   imagePreview.Source = bitmap;\r\n}<\/pre>\n<p><tt>SaveScreenshotAsync<\/tt> is an <tt>async<\/tt> method that takes the reference to the <tt>FrameworkElement<\/tt> to be rendered to a bitmap (in this case the <tt>constrolsGrid<\/tt>) and returns a <tt>Task&lt;RenderedTargetBitmap&gt;<\/tt> that can be awaited on. As soon as we have the bitmap we set it as the source for the image control (<tt>imagePreview<\/tt>).<\/p>\n<p><a href=\"http:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1754\" alt=\"wsas2\" src=\"http:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas2.png\" width=\"588\" height=\"336\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas2.png 588w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas2-300x171.png 300w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><\/a><\/p>\n<pre class=\"lang:c# decode:true\">async Task&lt;RenderTargetBitmap&gt; SaveScreenshotAsync(FrameworkElement uielement)\r\n{\r\n   var file = await PickSaveImageAsync();\r\n\r\n   return await SaveToFileAsync(uielement, file);         \r\n}      \r\n\r\nasync Task&lt;RenderTargetBitmap&gt; PickSaveImageAsync()\r\n{\r\n   var filePicker = new FileSavePicker();\r\n   filePicker.FileTypeChoices.Add(\"Bitmap\", new List() { \".bmp\" });\r\n   filePicker.FileTypeChoices.Add(\"JPEG format\", new List() { \".jpg\" });\r\n   filePicker.FileTypeChoices.Add(\"Compuserve format\", new List() { \".gif\" });\r\n   filePicker.FileTypeChoices.Add(\"Portable Network Graphics\", new List() { \".png\" });\r\n   filePicker.FileTypeChoices.Add(\"Tagged Image File Format\", new List() { \".tif\" });\r\n   filePicker.DefaultFileExtension = \".jpg\";\r\n   filePicker.SuggestedFileName = \"screenshot\";\r\n   filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;\r\n   filePicker.SettingsIdentifier = \"picture picker\";\r\n   filePicker.CommitButtonText = \"Save picture\";\r\n\r\n   return await filePicker.PickSaveFileAsync();\r\n}<\/pre>\n<p><tt>SaveScreenshotAsync<\/tt> is an <tt>async<\/tt> method that takes the <tt>FrameworkElement<\/tt> to be rendered to a bitmap and returns a <tt>Task&lt;RenderedTargetBitmap&gt;<\/tt> that can be awaited on. This method first prompts the user to select a destination file for the rendered bitmap. When the file is available it calls <tt>SaveToFileAsync<\/tt> to rendered the bitmap and write it to the file.<\/p>\n<pre class=\"lang:c# decode:true\">async Task&lt;RenderTargetBitmap&gt; SaveToFileAsync(FrameworkElement uielement, StorageFile file)\r\n{\r\n   if (file != null)\r\n   {\r\n      CachedFileManager.DeferUpdates(file);\r\n\r\n      Guid encoderId = GetBitmapEncoder(file.FileType);\r\n\r\n      try\r\n      {\r\n         using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))\r\n         {\r\n            return await CaptureToStreamAsync(uielement, stream, encoderId);\r\n         }\r\n      }\r\n      catch(Exception ex)\r\n      {\r\n         DisplayMessage(ex.Message);\r\n      }\r\n\r\n      var status = await CachedFileManager.CompleteUpdatesAsync(file);\r\n   }\r\n\r\n   return null;\r\n}\r\n\r\nGuid GetBitmapEncoder(string fileType)\r\n{\r\n   Guid encoderId = BitmapEncoder.JpegEncoderId;\r\n   switch (fileType)\r\n   {\r\n      case \".bmp\":\r\n         encoderId = BitmapEncoder.BmpEncoderId;\r\n         break;\r\n      case \".gif\":\r\n         encoderId = BitmapEncoder.GifEncoderId;\r\n         break;\r\n      case \".png\":\r\n         encoderId = BitmapEncoder.PngEncoderId;\r\n         break;\r\n      case \".tif\":\r\n         encoderId = BitmapEncoder.TiffEncoderId;\r\n         break;\r\n   }\r\n\r\n   return encoderId;\r\n}\r\n\r\nasync void DisplayMessage(string error)\r\n{\r\n   var dialog = new MessageDialog(error);\r\n\r\n   await dialog.ShowAsync();\r\n}<\/pre>\n<p><tt>SaveToFileAsync<\/tt> is an <tt>async<\/tt> method that takes the <tt>FrameworkElement<\/tt> to be rendered to a bitmap and the <tt>StorageFile<\/tt> when the bitmap is to be saved and returns a <tt>Task&lt;RenderedTargetBitmap&gt;<\/tt> that can be awaited on. The file is opened asynchronous for read-write access and the returned <tt>IRandomAccessStream<\/tt> is passed further together with the framework element and the bitmap encoder id (that specifies how the bitmap should be encoded, i.e. BMP, JPEG, PNG, GIF, etc.) to <tt>CaptureToStreamAsync<\/tt>.<\/p>\n<pre class=\"lang:c# decode:true\">async Task&lt;RenderTargetBitmap&gt; CaptureToStreamAsync(FrameworkElement uielement, IRandomAccessStream stream, Guid encoderId)\r\n{\r\n   try\r\n   {\r\n      var renderTargetBitmap = new RenderTargetBitmap();\r\n      await renderTargetBitmap.RenderAsync(uielement);\r\n\r\n      var pixels = await renderTargetBitmap.GetPixelsAsync();\r\n\r\n      var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi;\r\n      var encoder = await BitmapEncoder.CreateAsync(encoderId, stream);\r\n      encoder.SetPixelData(\r\n          BitmapPixelFormat.Bgra8,\r\n          BitmapAlphaMode.Ignore,\r\n          (uint)renderTargetBitmap.PixelWidth,\r\n          (uint)renderTargetBitmap.PixelHeight,\r\n          logicalDpi,\r\n          logicalDpi,\r\n          pixels.ToArray());\r\n\r\n      await encoder.FlushAsync();\r\n\r\n      return renderTargetBitmap;\r\n   }\r\n   catch (Exception ex)\r\n   {\r\n      DisplayMessage(ex.Message);\r\n   }\r\n\r\n   return null;\r\n}<\/pre>\n<p><tt>CaptureToStreamAsync<\/tt> creates a new <tt>RenderTargetBitmap<\/tt> object and calls <tt>RenderAsync<\/tt> to render the visual tree of the framework element to a bitmap. After the bitmap is rendered it retries the image as a buffer of byes in the <tt>BGRA8<\/tt> format. It then asynchronously creates a <tt>BitmapEncoder<\/tt> for the <tt>IRandomAccessStream<\/tt> stream that it received as an argument, it calls <tt>SetPixelData<\/tt> to set the pixels data (notice the <tt>BitmapPixelFormat.Bgra8<\/tt> parameter that matches the pixels format returned by <tt>GetPixelsAsync<\/tt>) and later asynchronously flushes all the image data, basically writing it to the file. It then returns that <tt>RenderTargetBitmap<\/tt> object that it created, which is used eventually as the source for the image control.<\/p>\n<p>Here is how the saved JPEG image (also seen in the preview screenshot above) looks likes:<br \/>\n<a href=\"http:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1757\" alt=\"wsas3\" src=\"http:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas3.jpg\" width=\"705\" height=\"195\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas3.jpg 705w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas3-300x82.jpg 300w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/a><\/p>\n<p>You can check the source code of the attached <div class=\"wp-block-button\">\n<a  data-e-Disable-Page-Transition=\"true\" class=\"dlm-download-link dlm-download-default wp-block-button__link wp-element-button\" title=\"Version 1.0\" href=\"https:\/\/mariusbancila.ro\/blog\/download\/3499\/?tmstv=1791705348\" rel=\"nofollow\" id=\"download-link-3499\" data-redirect=\"false\" >\n\tWinRT Screenshot demo\t(<span class=\"dlm-download-count-value\">8571 downloads<\/span>\n\t)\n<\/a>\n<\/div>\n. It requires Visual Studio 2013 and Windows 8.1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In WPF, Silverlight and Windows Phone it is possible to render a visual object into a bitmap using the RenderTargetBitmap. This functionality, that I find pretty basic, was not available for Windows Store applications. Fortunately, Windows 8.1 provides that functionality for Windows Store applications too, through the same RenderTargetBitmap class. There are some limitations though: &#8230; <a title=\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\" class=\"read-more\" href=\"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/\" aria-label=\"Read more about Render the screen of a Windows Store App to a bitmap in Windows 8.1\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[11,8,289,21],"tags":[454,396,451,397,395,290,457],"class_list":["post-1750","post","type-post","status-publish","format-standard","hentry","category-csharp","category-windows-programming","category-winrt","category-xaml","tag-net","tag-bitmap","tag-c","tag-screenshot","tag-windows-store","tag-winrt-2","tag-xaml"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"winrt,windows store,xaml,c#,.net,bitmap,screenshot,c++\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\" \/>\n\t\t<meta property=\"og:description\" content=\"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2013-11-05T10:43:52+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2013-11-05T10:43:53+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#article\",\"name\":\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\",\"headline\":\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/wp-content\\\/uploads\\\/2013\\\/11\\\/wsas1.png\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#articleImage\",\"width\":800,\"height\":748},\"datePublished\":\"2013-11-05T12:43:52+02:00\",\"dateModified\":\"2013-11-05T12:43:53+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":11,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#webpage\"},\"articleSection\":\"C#, Windows Programming, WinRT, XAML, .NET, bitmap, C++, screenshot, windows store, winrt, XAML\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/#listItem\",\"name\":\".NET\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/#listItem\",\"position\":4,\"name\":\".NET\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/#listItem\",\"name\":\"C#\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/#listItem\",\"position\":5,\"name\":\"C#\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#listItem\",\"name\":\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/#listItem\",\"name\":\".NET\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#listItem\",\"position\":6,\"name\":\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/#listItem\",\"name\":\"C#\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/\",\"name\":\"Render the screen of a Windows Store App to a bitmap in Windows 8.1\",\"description\":\"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/11\\\/05\\\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2013-11-05T12:43:52+02:00\",\"dateModified\":\"2013-11-05T12:43:53+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","description":"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/","robots":"max-image-preview:large","keywords":"winrt,windows store,xaml,c#,.net,bitmap,screenshot,c++","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#article","name":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","headline":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2013\/11\/wsas1.png","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#articleImage","width":800,"height":748},"datePublished":"2013-11-05T12:43:52+02:00","dateModified":"2013-11-05T12:43:53+02:00","inLanguage":"en-US","commentCount":11,"mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#webpage"},"articleSection":"C#, Windows Programming, WinRT, XAML, .NET, bitmap, C++, screenshot, windows store, winrt, XAML"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/#listItem","name":".NET"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/#listItem","position":4,"name":".NET","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/#listItem","name":"C#"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/#listItem","position":5,"name":"C#","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#listItem","name":"Render the screen of a Windows Store App to a bitmap in Windows 8.1"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/#listItem","name":".NET"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#listItem","position":6,"name":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/#listItem","name":"C#"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/","name":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","description":"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2013-11-05T12:43:52+02:00","dateModified":"2013-11-05T12:43:53+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","og:description":"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.","og:url":"https:\/\/mariusbancila.ro\/blog\/2013\/11\/05\/render-the-screen-of-a-windows-store-app-to-a-bitmap-in-windows-8-1\/","article:published_time":"2013-11-05T10:43:52+00:00","article:modified_time":"2013-11-05T10:43:53+00:00","twitter:card":"summary","twitter:title":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","twitter:description":"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1."},"aioseo_meta_data":{"post_id":"1750","title":"Render the screen of a Windows Store App to a bitmap in Windows 8.1","description":"Learn how to render to a bitmap the visual tree of a framework element in a Windows Store application in Windows 8.1.","keywords":[{"label":"winrt","value":"winrt"},{"label":"windows store","value":"windows store"},{"label":"xaml","value":"xaml"},{"label":"C#","value":"C#"},{"label":".NET","value":".NET"},{"label":"bitmap","value":"bitmap"},{"label":"screenshot","value":"screenshot"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:11:01","updated":"2025-12-12 07:41:25","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":11,"uagb_excerpt":"In WPF, Silverlight and Windows Phone it is possible to render a visual object into a bitmap using the RenderTargetBitmap. This functionality, that I find pretty basic, was not available for Windows Store applications. Fortunately, Windows 8.1 provides that functionality for Windows Store applications too, through the same RenderTargetBitmap class. There are some limitations though:&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/\" class=\"advgb-post-tax-term\">C#<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/\" class=\"advgb-post-tax-term\">Windows Programming<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/winrt\/\" class=\"advgb-post-tax-term\">WinRT<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">XAML<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C#<\/span>","<span class=\"advgb-post-tax-term\">Windows Programming<\/span>","<span class=\"advgb-post-tax-term\">WinRT<\/span>","<span class=\"advgb-post-tax-term\">XAML<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">.NET<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">bitmap<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">screenshot<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">windows store<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">winrt<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/xaml\/\" class=\"advgb-post-tax-term\">XAML<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">.NET<\/span>","<span class=\"advgb-post-tax-term\">bitmap<\/span>","<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">screenshot<\/span>","<span class=\"advgb-post-tax-term\">windows store<\/span>","<span class=\"advgb-post-tax-term\">winrt<\/span>","<span class=\"advgb-post-tax-term\">XAML<\/span>"]}},"comment_count":"11","relative_dates":{"created":"Posted 13 years ago","modified":"Updated 13 years ago"},"absolute_dates":{"created":"Posted on November 5, 2013","modified":"Updated on November 5, 2013"},"absolute_dates_time":{"created":"Posted on November 5, 2013 12:43 pm","modified":"Updated on November 5, 2013 12:43 pm"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-se","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/1750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=1750"}],"version-history":[{"count":7,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/1750\/revisions"}],"predecessor-version":[{"id":1760,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/1750\/revisions\/1760"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=1750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=1750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=1750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}