Win2D 0.0.8 – async CreateResources, better DPI support, and CanvasSwapChain


Win2D version 0.0.8 is now available on NuGet and Github.

New this sprint (breaking changes highlighted in red):

  • CreateResources events can now register AsyncActions to be tracked. This simplifies writing async load functions, and makes it easier to robustly handle error cases such as device lost. During the week we will be posting a series of articles explaining the background and design process that led to this API.
  • Assorted tweaks to make high DPI devices easier to work with and more likely to do the Right Thing™ by default:
    • CanvasRenderTarget and CanvasImageSource sizes are now specified in dips rather than pixels.
    • Image effects automatically insert DPI compensation when a source bitmap has different DPI from the target device context.
    • Re-raise the CreateResources event in response to monitor DPI changes.
    • Added ICanvasResourceCreatorWithDpi interface.
    • Added DPI properties to CanvasBitmap, CanvasDrawingSession, CanvasImageSource, and CanvasControl.
    • Plumb DPI information through from one object to another in more places than we did before.
    • Fixed CanvasControl layout bug - at high DPI the child image control could get the wrong size.
    • Added DPI test to Example Gallery.
    • With these changes, everything in Example Gallery is now rendering correctly on high DPI devices!
  • Added CanvasSwapChain and CanvasSwapChainPanel.  These provide an alternative to CanvasImageSource, hosting Win2D graphics content inside XAML in a way that can be updated independently of the XAML UI renderer, which can provide smoother and lower latency animation.  These types are not currently very easy to use, though, so in the same way that CanvasControl sits on top of CanvasImageSource and handles a lot of the boilerplate operations for you, in the future we plan to add a CanvasAnimatedControl that will simplify working with CanvasSwapChain.
  • Renamed SaveToFileAsync and SaveToStreamAsync to SaveAsync (for consistency with LoadAsync)

Comments (0)

Skip to main content