Direct2D wrapper library for .NET applications. This library uses Direct2D graphics API to provide the high performance hardware accelerated instant rendering ability.
The graphics context class is designed like normal Windows Form GDI+ graphics API, easily use and user friendly.
Project | Language | Description | Output DLL |
---|---|---|---|
d2dlib | VC++ | Direct2D wrapper host side library, calling Windows SDK and Direct2D API | d2dlib.dll |
d2dlibexport | C# | Direct2D client side interface between .NET and VC++ library, calling d2dlib.dll | d2dlibexport.dll |
d2dlibexportwinform | C# | Provides the .NET classes like D2DWinForm and D2DControl that use Direct2D hardware-acceleration rendering | d2dlibwinform.dll |
- Compile every projects or use the DLLs from the binary folder directly
- Add
d2dlibexport.dll
andd2dlibwinform.dll
as application references - Put
d2dlib.dll
in theDebug
,Release
or folder where application runs - Make windows form or control inherited from
D2DForm
orD2DControl
class - Override
OnRender(D2DGraphics g)
method (do not override .NETOnPaint
method) - Draw anything inside
OnRender
method via theg
context
Notice
The platform target of application project must be set to x86 when using default build configuration.
g.DrawText("Hello World", D2DColor.Yellow, this.Font, 100, 200);
protected override void OnRender(D2DGraphics g)
{
var ellipse = new D2DEllipse(0, 0, 10, 10);
g.DrawEllipse(ref ellipse, D2DColor.Gray);
}
var bmpGraphics = this.Device.CreateBitmapGraphics(1024, 1024);
bmpGraphics.BeginRender();
bmpGraphics.FillRectangle(170, 790, 670, 80, new D2DColor(0.4f, D2DColor.Black));
bmpGraphics.DrawText("This is Direct2D device bitmap", D2DColor.Goldenrod, this.Font, 180, 800);
bmpGraphics.EndRender();
// draw this device bitmap on screen
g.DrawBitmap(bmpGraphics, this.ClientRectangle);
Learn more about Bitmap.
Fast images rendering See source code
Custom draw on memory bitmap See source code
Star space simulation See source code
Subtitle rendering See source code
Whiteboard App
See source code