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 apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.
Перейти к файлу
Sergio Pedri a8fec6c69a Merged PR 24469: Port ICanvasImageInterop features and other new APIs from UWP branch
This PR ports all the `ICanvasImageInterop` features and other new APIs from the UWP branch to the WASDK branch. The original PRs into the UWP branch are mostly unchanged, minus some tweaks here and there mostly around marshalling and some project file adjustments to make things work.

Included cherry-picked PRs:
- !23226
- !23817
- !23654
- !23663
- !24053
- !23861
2023-03-10 11:08:34 +00:00
build Update TargetPlatformVersion to 22621, remove net5 from name of project, change nuget dependency 2023-02-21 10:52:32 -05:00
eng Update the nightly WinAppSDK-based pipeline to run jobs in parallel 2023-02-03 14:46:48 -05:00
tools Update to toolchain 143 and update projection project to .NET 6 2023-02-09 12:43:20 -05:00
winrt Merged PR 24469: Port ICanvasImageInterop features and other new APIs from UWP branch 2023-03-10 11:08:34 +00:00
.gitattributes
.gitignore Merged PR 16895: Update Win2D to Reunion 1.0.0-experimental1 2021-08-27 22:59:47 +00:00
.sscignore Merged PR 22672: Ignore CFS warning since the pipeline works around it 2022-09-28 17:04:34 +00:00
CHANGELOG.md Update Changelog for 1.0.4 2022-10-04 17:22:39 -04:00
CONTRIBUTING.md Add ARM64 support (#722) 2019-09-06 15:30:24 -07:00
LICENSE.txt
Microsoft.Graphics.Win2D.sln Update TargetPlatformVersion to 22621, remove net5 from name of project, change nuget dependency 2023-02-21 10:52:32 -05:00
README.md Merged PR 24469: Port ICanvasImageInterop features and other new APIs from UWP branch 2023-03-10 11:08:34 +00:00
SECURITY.md Microsoft mandatory file 2022-08-31 15:23:16 +00:00
Win2D.proj Update TargetPlatformVersion to 22621, remove net5 from name of project, change nuget dependency 2023-02-21 10:52:32 -05:00
build.cmd Merged PR 20415: Update Win2D to WinAppSDK 1.0.3 2022-04-28 15:37:47 +00:00
global.json Update TargetPlatformVersion to 22621, remove net5 from name of project, change nuget dependency 2023-02-21 10:52:32 -05:00
nuget.config Merged PR 19015: Pull changes for nightly branch into master 2022-02-09 18:30:51 +00:00
runbuild.ps1 Merged PR 16988: Fix AnyCPU compilation 2021-09-08 14:44:56 +00:00
smoke.cmd Remove 8.1 support: assorted other cleanups 2018-02-23 15:25:05 -08:00

README.md

Transitioning Win2D to Reunion is In-Progress

Moving Win2D over to WindowsAppSdk and WinUI3 is a work in progress, and some features such as CanvasAnimatedControl have partial or no support.

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 apps for WinUI3. It utilizes the power of Direct2D, and integrates seamlessly with XAML.

Visit the DirectX Landing Page for more resources for DirectX developers.

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 C++/WinRT:

void MainPage::CanvasControl_Draw(CanvasControl const& sender, CanvasDrawEventArgs const& args)
{
    args.DrawingSession().DrawEllipse(155, 115, 80, 30, Colors::Black(), 3);
    args.DrawingSession().DrawText(L"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
  • Visual Studio 2019 16.9 with Tools for Universal Windows Apps 15.0.27428.01 and Windows SDK 18362
Clone Repository
Build NuGet Packages
  • Launch 'Developer Command Prompt for VS2019'
  • 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.