Win2D Example Gallery now available in the Windows and Phone Store


The Win2D Example Gallery test/sample/demo app is now available in the Store:

We decided to publish this after JohnnyWestlake discovered a regression in our last-but-one version that was blocking Phone app publishing.  Thanks for that report Johnny!  Having learned that such problems are possible, it seemed like a good idea to start publishing an app of our own to make sure everything is working as it should 🙂


Comments (4)

  1. Alex B. says:

    Is there a way to keep the CanvasControl from being cleared?

    I have created a class that keeps track of invalid parts and I want to redraw only this parts.

    The problem is as soon as I trigger the Draw() event with Invalidate() the Control get's cleared.

    I have set the ClearColor to transparent which didn't help, it just defaults to black.

    I tried the Set ClearColor to null but it's not nullable.

    Also is it possible to draw to a Bitmap or Blit inside the Control?

    That would be useful to implement faster scrolling.

    Thanks

     Alex

  2. DamyanPepper says:

    Hi Alex,

    The short answer is: no, the control always gets cleared.  You either want to just redraw the entire control or render to an intermediate CanvasRenderTarget if you want to preserve contents between frames.  CanvasDrawingSession.DrawImage can be used to draw a bitmap inside a control.

    The longer answer:

    The surface that CanvasControl renders to is managed by the OS so that it can be efficiently composited with the other elements on screen.  Generally, this means that you cannot draw to something that is currently being displayed.

    Note that some support for this is exposed if you use CanvasImageSource directly -- see the "Image Source Update Region" example in ExampleGallery for this.  With this you can specify a region to update. However, the region still needs to be cleared (since the initial content is undefined as the OS reuses regions of the existing surfaces).  Also, when you start using CanvasImageSource directly you take responsibility for the things that CanvasControl does for you (such as handling resizing, DPI changes and lost devices.)

    If you want the previous contents of the control to persist between frames then the best way to do this is through a CanvasRenderTarget - this can be drawn to without clearing the previous contents.  The CanvasDrawingSession.DrawImage method can then be used to draw the render target into your control. I've added an item to our backlog to add an example that demonstrates this technique.

    As another observation, I suspect that you may find that Win2D is fast enough at drawing that you can get away with redrawing the entire control each time, so tracking invalid parts may not be necessary.

    I hope this helps!

  3. Alex B. says:

    Hi Damyan,

    thanks for the quick repsonse.

    I want use the control to display and edit some complex vectorgraphics and not as a control per se.

    Indeed I haven't run into problems yet with the performance using my simple examples, but a proper design will allow more complex graphics on less advanced devices and also save battery time.

    I think the CanvasRenderTarget is what I was looking for, somehow  missed it in the documentation.

    Thanks

     Alex

  4. Scott Hutter says:

    Guys, this is wonderful.  Great work.  Im working on a game using this lib now actually and it really is working out well.  Kudos.

Skip to main content