Win2D 1.20.0 – bugfix release

Win2D version 1.20.0 is now available on NuGet (for Windows 10 or Windows / Phone 8.1) and GitHub.

Changes in this release:

  • The image effects that were added in Windows 10 Anniversary Edition (AlphaMaskEffect, CrossFadeEffect, OpacityEffect, and TintEffect) are no longer marked as experimental.
  • Made sure CanvasControl::Changed always executes on the UI thread. This fixes a crash during lost device recovery in multithreaded apps.
  • Close() clears its internal std::vector, to reduce memory usage.
  • Fixed XAML layout bug in the Example Gallery GlowTextCustomControl.
  • Fixed Example Gallery ink demo crash when you "clear" then "save".
  • Win2D doc build works with the latest version of Sandcastle.
  • test knows how to find the Windows SDK even if that is installed in subfolders (which is done to support side-by-side in more recent versions of Visual Studio).
  • Fixed HSTRING double-free in Win2D unit test.

Comments (26)

  1. zvi says:

    Why doesn’t have Offset Geometry function?
    it’s very, very important.
    (Not offset of the location, but the path geometry)

  2. You can offset a geometry while drawing it (eg. or alternatively apply an offset as part of the CanvasGeometry object itself (

    If neither of these meets your needs, can you give more details of what you are trying to do?

  3. Anastasios-Antonios Toulkeridis says:

    Great to see a blog post after so long.
    I love Win2D. Please continue development.

  4. OZR says:

    I wanna make fix 3d animated controls for WPF C# using DirectX C++ HLSL pixel-shader. Is there any easy way like win2d?

  5. Aaron Huang says:

    Thanks your grate team developed such a wonderful Win2D library.
    As Micrsoft’s software technology keeps moving fast, .net platform already migrated to many different OSes including Linux, MacOS, iOS, Android with .Net Core or Xamarin, and a great news is that .Net standard 2.0 will be released, with witch all .Net framework, .Net core and xamarin Apps can share the same code base.
    So, my question is, is there any plan for Win2D to support .Net core and Xamarin, so that we can use the same 2D engine for our cross-platform Apps? As I know there is a SkiaSharp that come from Xamarin, how do Microsoft to deal with the 2 libraries? will they be merge into one?

    1. Hi Aaron,

      We don’t currently have any plans to bring Win2D to platforms other than Windows/UWP.


      1. Aaron Huang says:


  6. Anastasios-Antonios Toulkeridis says:

    question please:
    I want to set individual pixels of a CanvasBitmap.
    What i currently do is create a Color array of appropriate size, set the Color array values in a loop and when the loop is finished i call the SetPixelColors method of CanvasBitmap to set the array.
    It would be more efficient in my case if i could set the Colors of the CanvasBitmap inside the loop (a “pset at” method). Is there a way? Or am i doing something silly? Perhaps the cost of the SetPixelColors call is negligible and there’s no need for a pset method?

    1. > I want to set individual pixels of a CanvasBitmap.

      If performance matters here, best advice I can give is “don’t do that”. Having CPU code set individual pixels into a GPU bitmap one at a time is pretty much the least efficient possible way to use a hardware optimized rendering API like Win2D.

      If you absolutely have to do software rendering on the CPU, it will be better to build up an array containing all the pixel data you want, then transfer that entire array to a Win2D bitmap in one go. This is why Win2D only offers APIs to set arrays of pixels, but not a single-pixel-at-a-time setter.

      But wherever possible, it will be better if you can design your rendering to avoid the CPU needing to set individual pixel values at all.

      1. Anastasios-Antonios Toulkeridis says:

        Thank you SO MUCH for the reply.
        I discovered myself how bad idea setting individual pixels would be in the meantime by experimenting 🙂

        FYI i’ve written my own 3D graphics engine and I’m using a Win2D canvasControl for drawing color values. In the future i’ll try to see if i can use more Win2D stuff other than just a drawimage call.
        Here’s a video of my engine

  7. Anastasios-Antonios Toulkeridis says:

    Dear Shawn, happy new year. Question please:
    if in the following line windowSize is equal to graphicsSize is this
    cds.DrawImage(graphicsCanvasBitmap, windowSize, graphicsSize, 1.0f, _interpolationToUse);
    the same as calling this?

    In other words, when sourceRect and destRect are equal and opacity is 1 does it ignore the interpolation? Or does it still do something and therefore the second line is faster?

    1. Specifying one of the more expensive interpolation modes (eg. cubic) will always be more expensive than a directly GPU hardware supported mode such as linear, regardless of whether or not you scale the image.

      If you use a cheap interpolation mode (eg. linear) the two overloads are equivalent.

  8. Anastasios-Antonios Toulkeridis says:

    Shawn please advise me!.
    I’ve created a VR version of my custom engine that uses Win2D for drawing.
    I have a controller app running on a PC that sends keyboard and mouse commands to a phone. The engine runs on the phone.
    It works quite well:
    Now i want to do it differently: i want the engine to run on the pc and send frames to the phone. All the phone will do is display received frames.
    I’ve implemented it like this: a take the same bytes that i use in my canvasbitmap loadbytes method and send those bytes to the phone. It works but even when the canvasbitmap is small the latency is significant.
    Is there a more efficient way to do it? Perhaps compress the bytes?
    I know the question is a bit outside the scope of Win2D but i could certainly use your advise.

    1. Anastasios-Antonios Toulkeridis says:

      Shawn don’t bother answering (Not that you were planning to anyway). I found a solution that works brilliantly. Specifically I encode the bytes into a JPG image and the send that JPG image to the mobile client.

  9. QuickC says:

    Will win2d be expected to work on windows IOT headed apps?

    1. Win2D should work on any device that supports the Universal Windows Platform (UWP)

  10. Imperial Dynamics says:

    Hello Shawn.
    I’ve been trying for the past 3 days to do something to no avail.
    I’m so tired and I haven’t figured it out.
    I have an image that i want to rotate
    This is the image:!AoqcPU6nkz_Ikd1GU346MKYKQJreuA

    At first it rotated in relation to the top-left corner.
    I figured out how to rotate in relation to the center with two translations.
    So it works:!AoqcPU6nkz_Ikd1EsYA7w7SUztf2rQ
    this is the code:!AoqcPU6nkz_Ikd1DrTDS35HQziQ8Pg

    However when i uncomment the view and projection matrices (i want the end result to have perspective) it doesn’t rotate correctly.
    One edge rotates unproportionally and eventually reaches infinity:!AoqcPU6nkz_Ikd1CgDi-BmYeUyFcmw

    camera vector is (0,0,10) , camera target is (0,0,-1000), fov is 60

    1. Imperial Dynamics says:

      I nailed it!
      I can now fill a rotating geometry with perspective.
      It was tricky to implement because the imagebrush transform doesn’t follow the transform of the geometry. The developer has to manually apply the transform.
      Please consider giving us the option. It would make developers far happier than the current implementation.

  11. Dennis says:

    One short question: Since the last version of Win2D (1.20.0) was released in November ’16, I would like to know if the project is still alive?
    Because I just realized that this awesome project exists and I want to use it for future projects. But I am a bit worried right now. Thank you 🙂

    1. No need to worry, Win2D is still an active project. Our rate of updates has slowed since early development when we were rapidly adding new features, but this is still being maintained and extended as new things are added to the underlying Windows platform.

      1. Dennis says:

        Thank you for the fast answer !

  12. RobMc says:

    Any plans to venture into the 3D side of Direct-X? Really like what you have done with 2D and use a lot of the api’s for my current app. However, would like to get into 3D and hence wondering if there are any plans. hopefully it is being discussed at least.

    thanks for a great product.



    1. Hi Rob,

      We don’t currently have any plans to add 3D rendering APIs to Win2D. If you want to access D3D from .NET, I recommend taking a look at SharpDX.

  13. Imperial Dynamics says:

    Shawn you’re a hard man to find. Could I have a more direct way to contact you (e.g. e-mail, social media, etc) coz i have a number of questions?
    For example, i find it hard to tell whether to use a CanvasRenderTarget or a CanvasCommandList.
    I modified the documentation example (that uses a CanvasCommandList) to use a CanvasRenderTarget instead with the same output:

    private void cac_CreateResources(Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.CanvasCreateResourcesEventArgs args)
    float width =(float) this.ActualWidth;
    float height =(float) this.ActualHeight;

    CanvasRenderTarget offscreen = new CanvasRenderTarget(sender, width, height, 96);
    CanvasCommandList cl = new CanvasCommandList(sender);

    using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
    using (CanvasDrawingSession clds = cl.CreateDrawingSession())
    for (int i = 0; i < 100; i++)

    Vector2 position = RndPosition();
    Color color = RndColor();

    clds.DrawText("Hello, World!", position, color);
    ds.DrawText("Hello, World!", position, color);

    blur = new GaussianBlurEffect();
    blur.Source = offscreen; //if we here use cl instead of offscreen the result is the same
    blur.BlurAmount = 10.0f;

    private void cac_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args)
    float radius = (float)(1 + Math.Sin(args.Timing.TotalTime.TotalSeconds)) * 10f;
    blur.BlurAmount = radius;

    1. To get support on using Win2D, please use the “report a bug or ask a question” link from this blog.

      1. Imperial Dynamics says:

        ok, I submitted the same question here

Skip to main content