Win2D 0.0.16 – breaking changes and Windows 10 support


Win2D version 0.0.16 is now available on NuGet and Github.

Breaking changes

As previously mentioned, this sprint focused on making breaking changes to improve the Win2D API design, in preparation for releasing a more stable version alongside the //build/ conference in a couple of weeks. 

Specifically:

1:  Split the Microsoft.Graphics.Canvas namespace into several new namespaces, to better group things and make the documentation easier to browse:

To update existing code:

  • In your .xaml files, change:
    xmlns:canvas="using:Microsoft.Graphics.Canvas.UI"
    to
    xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
  • In your .cs or .cpp files, add extra “using” statements for the new namespaces

2:  Reworked the DrawImage method to make its many overloads more consistent and easier to use. In particular, it is now possible to specify a destination rectangle or to modify opacity when drawing any ICanvasImage, rather than only a CanvasBitmap.

To update existing code:

  • If you were using one of the DrawImage overloads that changed, rearrange your parameters to match the new design

3:  Renamed and merged some CanvasTextFormat properties that experience had shown to be overly confusing.

 To update existing code:

  • Replace ParagraphAlignment with HorizontalAlignment
  • Replace FlowDirection and ReadingDirection with Direction

Windows 10 support

Win2D can now be built to support the Windows universal app platform. As this a preview, we are not shipping universal app platform binaries in the NuGet package at this time. In order to use Win2D with the universal app platform you'll need to build it from source. This is early work in progress, and some workarounds are required. Further instructions can be found here and here.

Finally, we added a particle system demo to the Example Gallery test app:


Comments (18)

  1. Juan Pablo GC says:

    Hello I have just compiled the source and and tested http://bit.ly/1GFSq4W. At the moment I have to say that takes to much time to compile my W10 App and the same in the W8 time is really fast.

    Of course really good job, I think Win2D allows devs to create the next high bar in Windows Apps but people will need more time to realize about this (my humble opinion).

    I have watched the particles system demo that it is in a CanvasAnimatedControl I understand it calls to update by itself like a XNA old days? Really great and smooth, I have tested in my 1320 and I have no words.

  2. juanpablogc says:

    Apart when I add in a UAP project it takes too much time to compile. I think it has something to be with System.Numerics. Is that true? will be solved?

  3. DamyanPepper says:

    Currently we need to build with .NET Native enabled in order for the System.Numerics.Vector support to work.  This is only a temporary work around and won't be necessary long term.

  4. ygc says:

    win2d is good, but why not give us win3d too?

  5. > why not give us win3d too?

    What would you want to see in such a thing that would be different from what SharpDX already provides?

  6. ygc says:

    "What would you want to see in such a thing that would be different from what SharpDX already provides?"

    —-SharpDX is third party's project, but I trust Microsoft more. I want something officially supported by Microsoft, just like previous XNA. Restarting or re-supporting XNA is also a good idea for Microsoft.

  7. ajh says:

    Not sure what the best platform is to post questions on technical problems….

    I have included Win2D v 0.0.16 via NuGet in a Windows Phone project. However, when using CanvasTextLayout and CanvasGeometry, I get errors like:

    {System.TypeLoadException: Requested Windows Runtime type 'Microsoft.Graphics.Canvas.Text.CanvasTextLayout' is not registered. —> System.Runtime.InteropServices.COMException: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

      — End of inner exception stack trace —

      at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)

      at Microsoft.Graphics.Canvas.Text.CanvasTextLayout..ctor(ICanvasResourceCreator resourceCreator, String textString, CanvasTextFormat textFormat, Single maximumLayoutWidth, Single maximumLayoutHeight)

      at PVOutput.HubPage.CanvasX_Draw(CanvasControl canvas, CanvasDrawEventArgs args, Int32 iDayX)}

    I do not see these classes in the generated AppxManifest.xml.

    Bug or am I missing a vital step somewhere ?

  8. Jason says:

    In the example it states to change from Any CPU to x86 – is this still the case for Windows Phone? As far as I'm aware all current phones are running on Arm.

  9. > Not sure what the best platform is to post questions on technical problems….

    The best way is to open an issue on GitHub:  github.com/…/new

    That lets us track status, see when a problem has been resolved, etc.

    Questions on this blog work fine too, but can get a little confusing if several different conversations start happening in parallel  🙂

    > I have included Win2D v 0.0.16 via NuGet in a Windows Phone project. However, when using CanvasTextLayout and CanvasGeometry, I get errors like:

    I have not seen that error before!  What type of project are you using?  (C#?  Targeting ARM architecture?)  and what version of Visual Studio?

  10. > In the example it states to change from Any CPU to x86 – is this still the case for Windows Phone?

    Select x86 if you want to run on an x86 device such as a PC, Surface, or the Windows Phone emulator.  Select ARM to run on ARM devices such as real Windows Phone hardware.

  11. Tibor says:

    Hi guys. I like Win2D. I'm currently working on app using this API. Is there any way to capture touch gestures  like hold, pinch, rotate etc. on canvas or animatedcanvas?

  12. Tibor says:

    Thank's for the advice Damyan. Unfortunately, when I want to process the PointerPoints in the PointerMoved event of the CanvasAnimatedControl.Input in the GestureRecognizer, I get an exception:

    "The Windows Runtime Object can only be used in the threading context where it was created, because it implements INoMarshal or has MarshalingBehaviorAttribute(MarshalingType.None) set. "

    The GR is a member of the MainPage on which is a Grid, in which is the CanvasAnimatedControl.

  13. DamyanPepper says:

    I'm guessing that you're creating the GestureRecognizer on something running on the UI thread (the constructor, or CreateResources).  I suggest you move the construction to your animated control's Update handler.

    (PS: github.com/…/new is a good place to submit support questions – blog comments tend to get a little tangled up after a while)

  14. Tibor says:

    Thank's for pointing me to the right place. Btw, creating the GR in the Update handler works, thanks!

  15. Johnny Westlake says:

    @Tibor – if you're having multiple pages, you can also hook / unhook the recogniser events using the RunOnGameLoopAsync() method during the pages OnNavigatedTo/From or Loaded/Unloaded events

  16. Tibor says:

    @Johnny – Thanks, I've already figured it out 🙂

  17. Ziya says:

    > What would you want to see in such a thing that would be different from what SharpDX already provides?

    1. High level 3d.

    2. SharpDX is low level.

    3. There is not existence of any single high level 3d graphics support for WinRT (I am not sure as I didn't scan all the WEB).

    4. Official. That means availability of official documentation incorporated in one single place on msdn along with other documentations. Also incorporated into one API (WinRT).

    5. WPF has close to high level 3d graphics support and that is great.

    6. We are talking about high level stuff that makes our life easier. That is why we wanna create 3d objects, animations, 2d shapes, GUI easily. Otherwise there would be no Win2d and high level WinRT at all.

    I hope we are not forced to use low level stuff to simply create great 3d graphics forever.

Skip to main content