Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing Windows apps for Windows 8.1, Windows Phone 8.1 and Windows 10. It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.

Subscribe to updates I use Win2D


Statistics on Win2D

Number of watchers on Github 1023
Number of open issues 42
Average time to close an issue 8 days
Main language C++
Average time to merge a PR 1 day
Open pull requests 2+
Closed pull requests 10+
Last commit over 2 years ago
Repo Created over 5 years ago
Repo Last Updated over 1 year ago
Size 40.9 MB
Homepage http://microsoft....
Organization / Authormicrosoft
Contributors13
Page Updated
Do you use Win2D? Leave a review!
View open issues (42)
View Win2D activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating Win2D for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing Windows apps for Windows 8.1, Windows Phone 8.1 and Windows 10. It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.

Where to get it
How to use it
More info

Code Example

To give you a flavor of what the code looks like, here is a snippet of XAML:

xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"

<Grid>
    <canvas:CanvasControl Draw="canvasControl_Draw" ClearColor="CornflowerBlue" />
</Grid>

and C#:

void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
    args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3);
    args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow);
}

or C++/CX:

void MainPage::CanvasControl_Draw(CanvasControl^ sender, CanvasDrawEventArgs^ args)
{
    args->DrawingSession->DrawEllipse(155, 115, 80, 30, Colors::Black, 3);
    args->DrawingSession->DrawText("Hello, world!", 100, 100, Colors::Yellow);
}

or VB:

Sub canvasControl_Draw(sender As CanvasControl, args As CanvasDrawEventArgs)
    args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3)
    args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow)
End Sub

Using Win2D

The documentation explains how to install Visual Studio, add the Win2D NuGet package to your project, and get started using the API.

Building Win2D from source

Requirements
  • Recommended: Visual Studio 2017 with Visual Studio Tools for Universal Windows Apps 15.0.26430.06
  • Visual Studio 2013 Update 5 is also supported (for Windows 8.1 or Windows Phone 8.1 development only)
Clone Repository
  • Go to 'View' -> 'Team Explorer' -> 'Local Git Repositories' -> 'Clone'
  • Add the Win2D repository URL (https://github.com/Microsoft/Win2D.git) and hit 'Clone'
Build NuGet Packages
  • If using Visual Studio 2017:
    • Launch 'Developer Command Prompt for VS2017'
  • If using Visual Studio 2013:
    • In Windows search, type 'Visual Studio Tools', and select that folder to open it
    • Launch 'Developer Command Prompt for VS2013'
  • Change directory to your cloned Win2D repository and run 'build'
Point Visual Studio at the resulting 'bin' directory
  • In Visual Studio, go to 'Tools' -> 'NuGet Package Manager' -> 'Package Manager Settings'
  • Choose 'Package Sources'
  • Click the '+' button to add a new source
  • Set 'Name' to 'Win2D' (or a name of your choosing)
  • Set 'Source' to the full path to the 'bin' directory (inside your cloned Win2D repository)
  • Click the 'Update' button
  • Click 'OK'

Locally built versions of Win2D are marked as prerelease, so you must change the 'Stable Only' setting to 'Include Prerelease' when adding them to your project.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Win2D open issues Ask a question     (View All Issues)
  • about 3 years Garbage collector impact on smooth animation
  • about 3 years Cannot create instance of type 'Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl'
  • about 3 years Question: Win2D on Raspberry Pi performance
  • about 3 years The presence of old Visual C++ distributables makes Win2D act unreliably
  • about 3 years Invalidate on HighContrastChanged
  • about 3 years MediaCapture with GPU based IBasicVideoEffect issue still there
  • about 3 years dxcap -forcetdr can crash CanvasAnimatedControl due to DXGI_ERROR_WAS_STILL_DRAWING
  • about 3 years ExampleGallery Ink demo crashes when you "clear" then "save"
  • about 3 years CanvasComposition.CreateDrawingSession should allow specifying DPI
  • over 3 years Wrong rendering if sprite batches are used back-to-back (OS bug)
  • over 3 years Performance optimization best practices?
  • over 3 years Need more text samples
  • over 3 years TDR after resuming app on Surface 3 (graphics driver bug)
  • over 3 years WINMDEXP : error WME1007: Could not resolve reference 'Assembly(Name=Windows.Foundation.FoundationContract (Visual Studio bug)
  • almost 4 years Win2D and SharpDX interop in C#
  • almost 4 years sample showing how to incorporate scenegraph
  • almost 4 years Expose IDWriteGlyphRunAnalysis (getting a SW alpha texture for a glyph run)
  • almost 4 years Expose IDWriteTextLayout3::InvalidateLayout
  • almost 4 years Expose color fonts
  • almost 4 years Expose IDWriteFontFace1::GetDesignGlyphAdvances
  • almost 4 years Expose IDWriteFactory1::GetEudcFontCollection
  • almost 4 years Expose all the options in IDWriteFactory::CreateCustomRenderingParams
  • almost 4 years Expose IDWriteFontFileStream (load fonts from a stream, not just a URI)
  • almost 4 years Make an OpenType tag from a string of four characters (to pass to typography APIs)
  • almost 4 years Expose pair kerning options
  • almost 4 years Expose font file accessors
  • almost 4 years Enable font streaming
  • almost 4 years Expose glyph design metrics (converted to em space)
  • almost 4 years Support custom (non-system) font fallbacks
  • almost 4 years Expose IDWriteFontSetBuilder
Win2D open pull requests (View All Pulls)
  • Ensure CanvasVirtualControl gets initialized on CoreWindow.WindowVisibilityChanged event.
  • Win2D geometry interop with RS4 Windows.UI.Composition.CompositionPath
Win2D questions on Stackoverflow (View All Questions)
  • How to use vertex shader via Win2d
  • Prevent Win2D Animated Canvas from clearing
  • Win2d blur doesn't always work in c++
  • Win2D CanvasBitmap vs Microsoft.UI.Composition CompositionImage
  • Vector2 types in Win2D drawing method inconsistency
  • Memory issue with win2D in winrt app
  • How to create a blurred background dialog box using Win2D?
  • how to get a drawingsession from a canvascontrol (win2d)
  • VB.Net make a image in background task using Win2d
  • How to trim text in Win2D using geometry
  • How to apply Win2D Blur effect to a picture from gallery?
  • How to calculate the size of a piece of text in Win2D
  • How to get the width and height of a Win2D CanvasBitmap during CreateResources?
Win2D list of languages used
Other projects in C++