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 (21)

  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. https://microsoft.github.io/Win2D/html/M_Microsoft_Graphics_Canvas_CanvasDrawingSession_DrawGeometry_6.htm) or alternatively apply an offset as part of the CanvasGeometry object itself (https://microsoft.github.io/Win2D/html/M_Microsoft_Graphics_Canvas_Geometry_CanvasGeometry_Transform.htm)

    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.

      Thanks,

      1. Aaron Huang says:

        Thanks!

  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 https://www.youtube.com/watch?v=cdb51JERbr8

  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?
    cds.DrawImage(graphicsCanvasBitmap);

    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: https://www.youtube.com/watch?v=dZOSzkMzhaQ
    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.
    THANK YOU,
    Anastasios

    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:
    https://1drv.ms/i/s!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:
    https://1drv.ms/i/s!AoqcPU6nkz_Ikd1EsYA7w7SUztf2rQ
    this is the code:
    https://1drv.ms/i/s!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:
    https://1drv.ms/i/s!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! https://youtu.be/JvVbHxXDYw0
      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 !

Skip to main content