locked
WriteableBitmap.Render() equivalent for Metro? RRS feed

  • General discussion

  • I would like to create a "screenshot" bitmap of my metro app like you could with WriteableBitmap.Render().  Is there a way to do this?

    I see the Windows.UI.Xaml.Media.Imaging.WriteableBitmap class, but it has no Render method and I don't see any other method that takes a visual or ui element.

    Thanks,

      Mary Ellen Chaffin

    Thursday, September 22, 2011 12:56 AM

All replies

  • Render() is not available in the developer preview. 

    Regarding your scenario thought...you mentioned screenshot.  Would you want the entire screen or a specific hierarchy of your visual tree?


    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer
    Thursday, September 22, 2011 4:59 AM
  • We really have 2 scenarios.  The first is a full screen shot where we'd like to get the image and then enable users to "Share" it via emal or socialite or whatever other apps implement that contract.

    The second scenario is where we'd like to have our live tile cycle through images of certain portions of a report. 

    So to answer your question, we really would need both.  It seems like it could be accomplished by having a single mechanism that could render a UIElement as a bitmap since the full screen (the Window) is also a UIElement just as the portions of our report are UIElements (for example, each graph would also be a UIElement).

    Given that a "Render" method is not available in the preview (which would make it very simple), is there a way around this (while it might involve writing a lot of additional code)?

    Thanks,

      Mary Ellen

    Thursday, September 22, 2011 5:23 AM
  • Tim,

    I just installed Win8 Consumer Preview and there is still no .Render() method on WriteableBitmap.

    We plan to port big diagramming application from Silverlight 5 to Win8 (http://grapholite.com/) and it's real show-stopper for us since there is no way to export our drawings as an image.

    Do you plan to include this method? Is there any workarounds?


    Eugene Akinshin

    Thursday, March 1, 2012 4:01 AM
  • Since you have the Consumer Preview, you could try http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.imaging.surfaceimagesource.aspx

    This will give you a shared DirectX surface which you could use to create a high-performance renderer in DirectX.

    Thursday, March 1, 2012 1:16 PM
  • It's cool that you can mix in DirectX into XAML apps, but if it only works in C++ apps - it is going to be a big block for people who want to port WPF/Silverlight apps or don't speak C++ or simply don't have time to code in C++ which is a more involved process.

    Filip Skakun

    Thursday, March 1, 2012 4:09 PM
  • I understand that people who invested heavily in WPF/Silverlight/managed might not be able to migrate there apps 1:1 to WinRT. I feel you pain.

    However, I also strongly believe that some tasks (like bitmap manipulation, 3D, 2d-effects, etc.) are best suited to be done in DirectX. For example, you can create your app logic in XAML&C# and have one WinRT component (DirectX/C++) which understands the primitives you want to draw. You get the best of both worlds. I mean, that's the beauty of WinRT - making interop with native capabilities easy and painless. Your alternative would be to do everything in C# and not use the native capabilities of the hardware (many CPU cycles await you). Yes, it might be 'hard' but at least if the framework does not provide the capability, you can make your own component. This is something I have been really fighting in the past with WPF based applications. I am not aware of a single WPF application that performs well. And that's just sad.

    What kind of devs are we, if we 'fear' C++ ? Metro Style apps have to run on low powered devices like tablets with touch screens. People expect a performant way to interact with the UI. They will also expect the devices to consume very little power. And frankly, I am not interested in thousand variations of data bounded lists.

    I know that Vectorform also did some Windows Phone 7 app and I can't imaging you did not complain about the lousy UI perf.

    Friday, March 2, 2012 8:56 AM
  • We did make quite a few Windows Phone apps and on a small device performance can be a problem, but that is also where we could very often use WriteableBitmap.Render() to improve it. Don't get me wrong - I really do appreciate an ability to do interop with DirectX - I am actually focusing my studies there right now, but this is solving an entirely different problem than that single method. There are areas where you could just call it (if it existed) and achieve your expected results in a matter of minutes and without it - you would need ti rewrite your app or a significant section of it in C++/DirectX which even if you know how to do it - will take you so much time that it will render a feature too expensive to implement. There is a reason why people do not frequently implement business applications in DirectX and why WPF made it feasible to develop visually appealing UIs.

    Filip Skakun

    Friday, March 2, 2012 1:53 PM
  • I understand that people who invested heavily in WPF/Silverlight/managed might not be able to migrate there apps 1:1 to WinRT. I feel you pain.


    So now we need DirectX in order to draw some rectangles and circles on canvas? Great!

    I don't fear C++, after all I wrote programs in C, assembler, and directly in machine codes. But it's seems very silly to me to rewrite all drawing logic just to be able to save drawings to bitmap. And performance is not issue in our case - in silverlight we render all graphics to Xaml visual tree and it's fast enought even if we perform complex realtime manipulations with whole picture. And when we export drawing to the bitmap the most time-consuming part is the png\jpeg encoding.



    Eugene Akinshin

    Friday, March 2, 2012 2:32 PM
  • @PaulX: DirectX is not a good practical solution for most developers. For instance, if the intent is to share an image of a document being displayed in a XAML-based app, or any number of such scenarios, implementing that functionality in DirectX would mean re-implementing the layout engine of XAML just to get an image out of the app. That's just not feasible. It's not about C++ vs C#. This affects C++ XAML developers as much as C# XAML developers.

    • Edited by JeroMiya Friday, March 2, 2012 2:57 PM
    Friday, March 2, 2012 2:53 PM
  • Another use case where this method would be irreplaceable - to implement transitions that involve copying the animated element - as in the Windows 8 start screen when you rearrange tiles and they slide out of view in one place while they start showing up in another.

    Come on - we really need it!

    Filip Skakun

    Saturday, March 3, 2012 12:00 AM
  • I would like to create a "screenshot" bitmap of my metro app like you could with WriteableBitmap.Render().  Is there a way to do this?

    I see the Windows.UI.Xaml.Media.Imaging.WriteableBitmap class, but it has no Render method and I don't see any other method that takes a visual or ui element.

    Thanks,

      Mary Ellen Chaffin


    I also have this problem. I have an existing WPF application that works beautifully in Windows 7, and it's not using any of the default controls, the entire screen is drawn. I'd like to put that to Windows 8 with just a few lines of code, but it seems that there is no onPaint or onRender method for me to use. It's also silly to rewrite the whole drawing logic in DirectX, after all, it works in WPF and Windows 7.
    Wednesday, March 14, 2012 4:31 PM
  • Same here, can we vote on the inclusion of a .Render() method?
    Thursday, April 12, 2012 1:33 PM
  • Add my vote for getting an image of both the full screen and part of the visual tree.
    Wednesday, April 18, 2012 9:44 PM
  • Tim, this is super important for us also. Used often in caching and printing and preview thumbnails.
    Monday, April 30, 2012 9:45 PM
  • Same here, can we vote on the inclusion of a .Render() method?
    Monday, May 7, 2012 6:28 AM
  • this is super important for us also
    Monday, May 7, 2012 7:32 AM
  • this is super important for us also.

    I can't understand why MS doesn't provide this function and REALLY wonder why MS can't explain the main reason not to provide this function.

    Please, Explain the reason why this function is removed. Are there any performance issues or  security issues?

    I convince that MS will lose many partnership by this issue because we (many developers) should implement a lot only just for porting previous WPF or Silverlight app.


    Tuesday, May 15, 2012 11:21 AM
  • I'm voting for this too


    notacat

    Tuesday, May 15, 2012 5:23 PM
  • Is there any development on this issue ?
    Monday, May 21, 2012 1:27 PM
  • Please add my vote too. Give me the WriteableBitmap constructor (UIElement, Transform) and a Save() method.
    Thursday, June 7, 2012 1:30 PM
  • Me too. I am working in D3D under WinRT and I need to write Text to Textures. 

    - Since D3D10, the pathway to using a texture as a D2D surface has been closed. 

    - The cartwheels required to simultaneously run a D3D10 device and a D3D11 device on the same hardware is unacceptably difficult, particularly since I'm working in MDX / (SharpDX). 

    - Now I can't render to a bitmap either, so seemingly all pathways to doing this are closed. 

    - WritableBitmapEX just dropped a couple days ago, and it doesn't save the day with any text rendering capability, either (though thank the stars it gave me a block-copy). 

    Lack of functionality to write anything useful to a bitmap is an unacceptable omission. This is a snap in Android or iOS, and as a non-game, enterprise & scientific developer, I'm feeling left in the lurch.

    Friday, June 15, 2012 3:04 AM
  • There seems to be a Direct2D save to image file sample that shows D2D and DWrite being used to write to file. Isn't that what you want?

    Filip Skakun

    Friday, June 15, 2012 7:24 AM
  • Thanks for the suggestion.  

    First: I should have been more specific. I need to write text to textures at runtime, with said textures being generated offscreen while I'm simultaneously running a D3D render loop. I'm a little doubtful that this approach will work, since I've already bound the D2DDevice to the Swap Chain of my rendering engine. Still, worth a try...

    But I immediately fall down at line 223 of SafeAsImageFileSample.cpp. I need to create an IStream that is backed by either a byte[] or a writable WIC image. Here I am writhing around in IBuffer, IRandomAccessStream, IInputStream, IOutputStream, MemoryStream... none of which appear to be interoperable. Am I missing a basic concept, or are the WinRT api designers insane? (Obviously probably the former, not the latter)

    So yeah, for your proposed solution: How does one wrap a byte[] in an IStream to supply to a BitmapEncoder ->In C#<-?


    • Edited by Xtrafe Friday, June 15, 2012 5:31 PM
    Friday, June 15, 2012 5:29 PM
  • Maybe something in this sample could help you:

    http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/14648#270540

    Just a wild shot though.


    Filip Skakun

    Friday, June 15, 2012 8:01 PM
  • Thanks again for the pointer. After looking a little more, in the first Code Sample you pointed me to, it appears what's going on is that the code is wrapping an encoder around a bitmap that is already getting properly drawn by D2D and pushing that out to a file. My situation is a little different, as I need to create a separate bitmap offscreen, use it as a D2D target, and then blip its pixels into a texture. The sticking point is that I can't get D2D to render onto my offscreen bitmaps.

    After another day of banging my head against the wall, I've made little progress. I've come up with some approaches; Neither crash, and both create usable texture objects, but no D2D drawing occurs. (So I wind up with black in the 1st attempt, and random pixels in the 2nd). I'm no DX expert, and I expect I'm missing some fundamental concept about what actually causes D2D to do a drawing cycle. Does anybody have any ideas? Thanks for your time :)

    //_target is a bunch of information about the current ->D3D11<- target in which the texture will finally be used.

    public Object AllocateTexture(DrawingSize drawingSize, DXDelegates.RenderD2DDelegate renderDelegate) { var pitch = drawingSize.Width * 4; var size = pitch * drawingSize.Height; var bufferArray = new Byte[size]; var dataStream = SharpDX.DataStream.Create(bufferArray, true, true); var dataRectangle = new SharpDX.DataRectangle(dataStream.DataPointer, pitch); var wicBitmap = new SharpDX.WIC.Bitmap(_target.DeviceManager.WICFactory, drawingSize.Width, drawingSize.Height, SharpDX.WIC.PixelFormat.Format32bppPRGBA, dataRectangle); var properties = new RenderTargetProperties(); properties.DpiX = _target.DeviceManager.Dpi; properties.DpiY = _target.DeviceManager.Dpi; properties.PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied); properties.Type = RenderTargetType.Default; var wicRenderTarget = new WicRenderTarget(_target.DeviceManager.FactoryDirect2D, wicBitmap, properties); renderDelegate.Invoke(wicRenderTarget, _target.DeviceManager); dataStream.Seek(0, SeekOrigin.Begin); return TextureLoader.CreateTexture2DFromBitmap(_d3dDevice, drawingSize.Width, drawingSize.Height, dataStream); } public Object AllocateTexture2(DrawingSize drawingSize, DXDelegates.RenderD2DDelegate renderDelegate) { var pitch = drawingSize.Width * 4; var size = pitch * drawingSize.Height; var localD2DContext = ToDispose(new SharpDX.Direct2D1.DeviceContext(_target.DeviceManager.DeviceDirect2D, SharpDX.Direct2D1.DeviceContextOptions.EnableMultithreadedOptimizations)); //Copy the bitmap properties out of the current target as much as possible. var bitmapProperties = new BitmapProperties1(); bitmapProperties.DpiX = _target.DeviceManager.Dpi; bitmapProperties.DpiY = _target.DeviceManager.Dpi; bitmapProperties.PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied); bitmapProperties.BitmapOptions = BitmapOptions.Target | BitmapOptions.CannotDraw; //Allocate a buffer and wrap a Surface-Compatible bitmap aroun it. var backingBuffer = new DataStream(size, true, true); var renderTargetBitmap = new Bitmap1(localD2DContext, drawingSize, backingBuffer, pitch, bitmapProperties); localD2DContext.Target = renderTargetBitmap; //Scribble in the buffer so we can see what is and isn't working. var rand = new Random(); var randBuffer = new byte[size]; for (int i = 0; i < randBuffer.Length; i++) randBuffer[i] = (byte)rand.Next(0, 255); backingBuffer.Write(randBuffer, 0, size); backingBuffer.Seek(0, SeekOrigin.Begin); //Create a render target //This is unneccesary, perhaps? RenderTargetProperties properties = new RenderTargetProperties(); properties.DpiX = bitmapProperties.DpiX; properties.DpiY = bitmapProperties.DpiY; properties.PixelFormat = bitmapProperties.PixelFormat; properties.Type = RenderTargetType.Default; RenderTarget bitmapRenderTarget = new RenderTarget(_target.DeviceManager.FactoryDirect2D, renderTargetBitmap.Surface, properties); //All the actual D2D drawing happens in the delegate. renderDelegate.Invoke(bitmapRenderTarget, _target.DeviceManager); //Blit the buffer into a texture. var texture2D = TextureLoader.CreateTexture2DFromBitmap(_d3dDevice, drawingSize.Width, drawingSize.Height, backingBuffer); return new ShaderResourceView(_d3dDevice, texture2D); }

    //TextureLoader method

            public static SharpDX.Direct3D11.Texture2D CreateTexture2DFromBitmap(SharpDX.Direct3D11.Device device, int width, int height, SharpDX.DataStream dataStream)
            {        
                return new SharpDX.Direct3D11.Texture2D(device, 
                                                        standardTexture2D(width, height), 
                                                        new SharpDX.DataRectangle(dataStream.DataPointer, width * 4));     
            }

    //D2D drawing delegate

     DXDelegates.RenderD2DDelegate renderDelegate = delegate(RenderTarget target, DeviceManager deviceManager)
                {
                    target.BeginDraw();                          
                    var textFormat = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 96 * drawingSize.Width / 1920) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center };
                    var blueBrush = new SolidColorBrush(target, Colors.SteelBlue); 
                    var whiteBrush = new SolidColorBrush(target, Colors.White);
                    var rr = new RoundedRect();
                    rr.RadiusX = 20;
                    rr.RadiusY = 10;
                    rr.Rect = new RectangleF(30f, 30f, 200f, 200f);
                    target.Clear(Colors.Salmon);
                    target.DrawRoundedRectangle(rr, whiteBrush);
                    target.DrawText("Hello Label!", textFormat, new RectangleF(-drawingSize.Width / 2.0f, -drawingSize.Height / 2.0f, drawingSize.Width / 2.0f, drawingSize.Height / 2.0f), blueBrush);
                    target.Flush();
                    target.EndDraw();
                };



    • Edited by Xtrafe Saturday, June 16, 2012 12:27 AM
    Saturday, June 16, 2012 12:23 AM
  • Sorry, I am really no expert and I would have to do some research too. I would try the DirectX forums or talk to the developer of SharpDX or just keep analyzing the samples - DirectX is not simple. I am planning on doing some D2D work in the coming weeks so maybe I'll have an answer in a bit on my blog. Another place that has a sample (Paint2D) that I am very well aware of is the Windows API Code Pack, which was an earlier attempt by Microsoft to provide .NET wrappers for DX 10/11. I think it also creates an image from the render target from the screen, but it seems like the WicRenderTarget should also support calls like DrawRoundedRectangle or DrawTextLayout.

    Filip Skakun

    Saturday, June 16, 2012 1:29 AM
  • can we use WritableBitmapEx for saving the canvas content as image ? If yes, how ?
    Monday, July 16, 2012 6:56 AM
  • Any updates of WriteableBitmap.Render support in Windows 8 RTM? If it is still not available, are there other ways to have a screenshot for a specific hierarchy of visual tree?


    多彩日历 for Windows Phone: http://windowsphone.com/s?appid=c1e81a25-731b-43d0-800a-1c1d3ef8de79

    Monday, August 20, 2012 4:55 AM
  • Please add my vote too. Give me the WriteableBitmap constructor (UIElement, Transform) and a Save() method.

    And mine too... this is super critical for us!!
    Thursday, September 6, 2012 2:19 AM
  • me too :-(
    Sunday, September 9, 2012 5:55 PM
  • We're also having huge problems because of this.

    I was able to draw stuff on-screen with Direct2D but I don't know how to store it into a image for sharing.
    Do I need to make on-screen drawing in Direct2D and off-screen drawing in WriteableBitmapEx?

    And we also need a way to store whats on the screen for performance improvements.
    All of that was easy in WPF.

    Monday, September 10, 2012 1:09 PM
  • You can use this with WinRT XAML toolkit. (http://jupitertoolkit.codeplex.com/)

    The toolkit will give you the ability to save WriteableBitmap to file.
    You can also checkout this answer on this thread for C# + DirectX solution:
    http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/c64f5ab9-cc23-4c98-8478-8a8f4e5faeaa

    Here is a small tutorial for storing SharpDX content to file:
    http://geoffwebbercross.blogspot.co.uk/2012/09/exporting-image-from-directx-2d-image_15.html

    Thursday, September 20, 2012 8:53 AM
  • It's really super important for us too!!!

    So why MS remove it?

    YOU just have only 5000 apps at store and still REFUSE to help?


    It's Lin.

    Monday, October 29, 2012 7:23 AM
  • This is not about us developers knowing how to code in C++ and how to use DirectX. This is about how Microsoft developer's do not know how to code C++ and add render to bitmap. Either they are not capable of coding or the performance of their code was horrible so they opted to leave it out. Either way, they can't code.
    Tuesday, October 30, 2012 12:18 PM
  • Add me to the list of people who really want the Render() method. I have a visual tree in XAML that includes a canvas with the user's ink strokes. I want to get a bitmap of that tree (the canvas with strokes plus other visual elements in the UI, most notably an image behind the canvas) so I can share it using the share charm.

    Without Render() there's no way for me to get that into a bitmap. If Render() existed I'd have Share implemented in 5 minutes :(

    Neil

    Monday, November 19, 2012 3:10 AM
  • I have just worked on it for a very short time, but I am working on implementing some basic composition code to render a visual tree to a bitmap. Got it working for some basic TextBlocks for now, but I might add other pieces soon too.

    http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/585d3ae5a3e3#WinRTXamlToolkit.Composition%2fWriteableBitmapRenderExtensions.cs


    Filip Skakun

    Monday, November 26, 2012 6:31 PM
  • I understand that people who invested heavily in WPF/Silverlight/managed might not be able to migrate there apps 1:1 to WinRT. I feel you pain.

    However, I also strongly believe that some tasks (like bitmap manipulation, 3D, 2d-effects, etc.) are best suited to be done in DirectX. For example, you can create your app logic in XAML&C# and have one WinRT component (DirectX/C++) which understands the primitives you want to draw. You get the best of both worlds. I mean, that's the beauty of WinRT - making interop with native capabilities easy and painless. Your alternative would be to do everything in C# and not use the native capabilities of the hardware (many CPU cycles await you). Yes, it might be 'hard' but at least if the framework does not provide the capability, you can make your own component. This is something I have been really fighting in the past with WPF based applications. I am not aware of a single WPF application that performs well. And that's just sad.

    What kind of devs are we, if we 'fear' C++ ? Metro Style apps have to run on low powered devices like tablets with touch screens. People expect a performant way to interact with the UI. They will also expect the devices to consume very little power. And frankly, I am not interested in thousand variations of data bounded lists.

    I know that Vectorform also did some Windows Phone 7 app and I can't imaging you did not complain about the lousy UI perf.

    So, you are saying that C# xaml apps suck, and that's it? They are merely "training wheels" for the real thing? I thought that C# was supposed to be "a real thing", that's why I haven't decided to learn c++ yet. I'm not asking for some way to make a RPG shooter game or anything, we just want a render method. It is something that should be possible. Unfortunately, this new C# xaml platform is weird. It's WPF with certain random stuff removed. So using this is like trying to make due with a calculator with missing buttons. The original WPF was amazing, why didn't they just do a direct port? WPF was naturally well suited for metro.

    Does this mean that Microsoft is officially giving up on the whole goal of the .NET framework, and telling people that to do "real" stuff that they have to learn a different, more complicated language, and insert many more complexities into their programming life just to get a darn image of their UI?

    Tuesday, November 27, 2012 2:53 AM
  • To clarify, Filip's code does not use the Xaml renderer and cannot create an exact snapshot of the visual tree as it is displayed. Even fully implemented it won't replace all uses of WriteableBitmap.Render, but it could be very useful for a number of scenarios.

    It iterates through the visual tree to see what needs to be drawn (currently only solid colour TextBlocks) and then interops with Direct2D to custom render the text. Expanded to support other basic elements (Border and the Shapes will cover many composited controls) this could end up very useful.

    --Rob

    Tuesday, November 27, 2012 4:05 AM
    Moderator
  • Add me also to the list of people who need the Render() method. 
    Friday, December 7, 2012 6:17 PM
  • Let me know what kinds of elements you would need rendered from your visual tree and I will use it as a test case in my implementation of the method. As Rob said - this is not going to replace a built-in method in all scenarios, but I think with a few more days of work on it I could probably cover like 99% of them.

    Filip Skakun

    Friday, December 7, 2012 6:21 PM
  • I am interested in building a C# or C++ XAML WinRT app that would save a bing map to an image, so the map can be displayed in a live tile. Please add me to the list of people who would benefit from a WriteableBitmap constructor that accepts a UIElement, or an equivalent solution. 
    Monday, December 17, 2012 6:43 PM
  • If you want to save map as image you can use Bing map's Imagery API, then it is easy to put it in as live tile. There is also an app, called map2image which saves bing map to image.
    Monday, December 17, 2012 7:07 PM
  • Filip,

    Are you working on the WriteableBitmapRenderExtensions.cs more? This is an extremely useful tool that I am eager to use. I have begun implementing some other simple types, like Grid, but am most interested in the ImageBrush converter. I can see that you started it, but commented it out for later.

    Thank you for this excellent work.

    Best regards,
    Thaine Norris


    Thaine Norris

    Monday, January 28, 2013 5:03 AM
  • Hi,

    I am planning on adding more support there. The problem is the toolkit keeps growing in many directions and I am getting more and more requests for help, so it is a bit hard balancing all of this being done in my free time. There is a chance I will get back to it this week, but I wouldn't depend on it.

    What was it you did for Grid? It shouldn't need any rendering more than the background and adding supports for transformations support that applies to everything else like visibility, opacity, clip, render transforms, projections etc.


    Filip Skakun

    Monday, January 28, 2013 4:25 PM
  • Hello,

    Yes, I just added a simple class for Grid and presently only support background. But that gives me most of what I need at present. Because I am on a deadline with a WinRT project, I am just hacking together some things to support creating a print-resolution bitmap composed of other bitmaps and text. I am using a combination of the composition library (for text and borders) and your WriteableBitmap extensions such as FloodFill, etc. to create the finished product. I look forward to seeing more great things from your toolkit.

    Thanks again


    Thaine Norris

    Monday, January 28, 2013 5:22 PM
  • Cool, note that I am happy to accept contributions to the toolkit! :)

    Meanwhile watch the source page for new check-ins. Perhaps what you need will show up there soon!

    Can you share what app you're building?


    Filip Skakun

    Monday, January 28, 2013 5:26 PM
  • The current developers at Microsoft do not have the expertise to implement a print screen feature into there operating system.
    Tuesday, January 29, 2013 3:35 AM
  • I am sure they have lots of openings. You are free to apply at http://careers.microsoft.com

    Filip Skakun

    Tuesday, January 29, 2013 4:16 AM
  • Hello Filip,

    I might be interested in contributing in the future. 

    I am working on a photo booth application that is, of course, very image intensive!

    I know this is unrelated to the Render() discussion, but I have a WinRT memory leak question for you. I have a XAML Image object that displays a preview image. I set it like this:

                        var file = await m_folderSourceImages.GetFileAsync(strPhotoFileName);
                        using (Windows.Storage.Streams.IRandomAccessStream photoStream = await file.OpenAsync(FileAccessMode.Read))
                        {
                            WriteableBitmap wBmp = await BitmapFactory.New(1, 1).FromStream(photoStream);
                            imgStillPreview.Source = wBmp;
                        }

    I set it repeatedly as new images are captured from the webcam. I would expect that when the image is replaced that the old reference to the WriteableBitmap would be released and eventually the memory would be freed. However, this does not seem to be the case. If it runs long enough, the application will eventually throw and out of memory exception. Do you have any insight?

    Thank you,
    Thaine


    Thaine Norris

    Monday, February 4, 2013 5:08 PM
  • I don't know what your bitmap fluent API does, but the most common source of leaks I see is with event handlers that are never removed, so perhaps it has some of that in there. Other than that - check my SO thread on debugging memory leaks in WinRT:

    http://stackoverflow.com/questions/13730496/how-to-debug-memory-leaks-in-windows-store-apps


    Filip Skakun

    Monday, February 4, 2013 5:22 PM
  • Thank you for the link to your other article. I do not have any of those tools on my system such as WinDbg and SOS.dll. Do you know off hand where I would download those? Also, I don't know how to create a dump file from the process manager. I am running Windows 8 x64.

    Thank you


    Thaine Norris

    Monday, February 4, 2013 5:55 PM
  • You can download WinDbg as part of Windows SDK or as a standalone download of "Debugging Tools for Windows" from http://msdn.microsoft.com/en-US/windows/hardware/gg463009/

    To create a dump file - go to Task Manager, right click a proces and select "Create dump file".


    Filip Skakun

    Monday, February 4, 2013 9:26 PM
  • Microsoft folks, any update on this?
    As all of us say, it's not an option learn Monogame/DX/C++ just to render image tree to bitmap.

    What was trivial before, now is a nightmare for most of developers. If you're so good at suggesting using DX, why don't you spend some hours and give us WinRT component which can do that?

    Thanks.

    Waiting for a real working code sample or component still.

    Thursday, May 2, 2013 9:09 PM
  • Is there something specific missing in the WinRT XAML Toolkit's implementation that you need?

    To test - get the NuGet package from:

    http://nuget.org/packages/winrtxamltoolkit.Composition

    Then get your WriteableBitmap:

    WriteableBitmap wb = await WinRTXAMLToolkit.Composition.WriteableBitmapRenderExtensions.Render(element);

    There are many basic things missing from there (like support for Opacity or Visibility properties), but the ones you might need might be easy to add.


    Filip Skakun

    Thursday, May 2, 2013 9:41 PM
  • You did a great job, Filip!

    Though I miss essentials - Image and ImageBrush, I was going to use Xaml + Render to easy create new picture based on template + set of smaller pictures.

    For now seems I have to use SharpDX solution http://geoffwebbercross.blogspot.co.uk/2012/09/exporting-image-from-directx-2d-image_15.html

    Friday, May 3, 2013 7:15 AM
  • Image and imagebrush are there

    Filip Skakun

    Friday, May 3, 2013 1:32 PM
  • Hi, Filip!

    I've tried the WinrtXamlToolkit.Composition and there is one issue: The element you're trying to render should be inside visual tree. That limits the scenarios of using the rendering only to foreground tasks. :(

    Sunday, May 19, 2013 10:32 PM
  • Really? I haven't checked, but it should work, only you might need to call Measure() and Arrange() on your element to get it to perform its layout. The composition extensions only get the dimensions and various format properties from the element tree, so it shouldn't matter whether it is on screen or not. Actually one of its limitations is that it also renders elements that are collapsed or at 0 opacity.

    Filip Skakun

    Sunday, May 19, 2013 10:37 PM
  • Well, I got following exception calling measure/arrange manually.

    "Element not in visual tree".

    WinRTXamlToolkit.Controls.Extensions.VisualTreeHelperExtensions.GetBoundingRect(FrameworkElement dob, FrameworkElement relativeTo)
       at WinRTXamlToolkit.Composition.Renderers.ImageRenderer.<Render>d__0.MoveNext()

    Monday, May 20, 2013 6:20 AM
  • The Windows 8.1 Preview now provides this behavior via the RenderTargetBitmap class.

    --Rob

    Thursday, July 25, 2013 1:54 AM
    Moderator
  • Have a look at this sample,

    Windows 8 Input: Ink sample in C#/Xaml

    This sample has a function implemented to save the picture drawn by the user into a Image file.


    Pradeep AJ

    MyApp   MyBlog   MySamples



    • Edited by Pradeep AJ Thursday, July 25, 2013 2:31 AM
    Thursday, July 25, 2013 2:30 AM