{"id":16250924,"url":"https://github.com/jingwood/d2dlib","last_synced_at":"2025-04-12T19:52:25.219Z","repository":{"id":22980024,"uuid":"97792027","full_name":"jingwood/d2dlib","owner":"jingwood","description":"A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.","archived":false,"fork":false,"pushed_at":"2024-11-02T04:48:40.000Z","size":7025,"stargazers_count":256,"open_issues_count":46,"forks_count":49,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-12T19:52:18.039Z","etag":null,"topics":["acceleration","bitmap","direct2d","direct2d-api","direct2d-bitmap","dotnet","draw","drawing","gpu","graphics-context","hardward","immediate","library","memory-bitmap","performance","rendering"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jingwood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"unvell"}},"created_at":"2017-07-20T04:57:10.000Z","updated_at":"2025-03-21T14:21:24.000Z","dependencies_parsed_at":"2024-10-10T15:07:59.770Z","dependency_job_id":"7e8095a8-de50-4952-b06a-7c422cd2bf1b","html_url":"https://github.com/jingwood/d2dlib","commit_stats":{"total_commits":229,"total_committers":11,"mean_commits":"20.818181818181817","dds":0.1746724890829694,"last_synced_commit":"203ff73ac40a6ee1d55ca25f2c3b4ba1c9e1acda"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jingwood%2Fd2dlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jingwood%2Fd2dlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jingwood%2Fd2dlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jingwood%2Fd2dlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jingwood","download_url":"https://codeload.github.com/jingwood/d2dlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625506,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acceleration","bitmap","direct2d","direct2d-api","direct2d-bitmap","dotnet","draw","drawing","gpu","graphics-context","hardward","immediate","library","memory-bitmap","performance","rendering"],"created_at":"2024-10-10T15:07:46.660Z","updated_at":"2025-04-12T19:52:25.179Z","avatar_url":"https://github.com/jingwood.png","language":"C#","readme":"[![GitHub](https://img.shields.io/github/license/jingwood/d2dlib)](https://github.com/jingwood/d2dlib/blob/master/LICENSE.md) [![Nuget](https://img.shields.io/nuget/v/unvell.D2DLib.svg)](https://www.nuget.org/packages/unvell.D2DLib)\n\n# d2dlib\n\nA .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.\n\nBy using the graphics context to draw anything on windows form, control or draw in memory via Direct2D. The graphics interface is designed like the normal Windows Form graphics interface, it's easy-to-learn and user-friendly.\n\n| Project | Language | Description | Output DLL | \n| --- | --- | --- | --- |\n| d2dlib | VC++ | Wrapper host-side library, calling Windows SDK and Direct2D API | d2dlib.dll | \n| d2dlibexport | C# | Wrapper client-side library, export the interface provided from d2dlib | d2dlibexport.dll |\n| d2dwinform | C# | Provides the `D2DWinForm` and `D2DControl` classes that use Direct2D hardware-acceleration graphics context during rendering | d2dwinform.dll |\n\n# Installation\n\n## Get binary from NuGet\n\n```shell\ninstall-package unvell.d2dlib\n```\n\nOr install for x64 platform:\n\n```shell\ninstall-package unvell.d2dlib-x64\n```\n\n## Notes\n\nThe Direct2D API is a platform-associated API that requires the application to be targeted to either x86 or x64 platform. To run the application uses this library correctly, the `Platform target` of the project settings must be set to `x86` or `x64`.\n\n## Install manually\n\nLearn how to [install manually](../../wiki/Manual-installation)\n\n# Getting Started\n\n1. Make windows form or control inherited from `D2DForm` or `D2DControl` class\n2. Override `OnRender(D2DGraphics g)` method (do not override .NET `OnPaint` method)\n3. Draw anything inside `OnRender` method via the `g` context\n\n# Drawing\n\n## Draw rectangle\n\n```csharp\nprotected override void OnRender(D2DGraphics g)\n{\n  var rect = new D2DRect(0, 0, 10, 10);\n  g.DrawRectangle(rect, D2DColor.Red);\n}\n```\n\n## Draw ellipse\n\n```csharp\nvar ellipse = new D2DEllipse(0, 0, 10, 10);\ng.DrawEllipse(ellipse, D2DColor.Gray);\n```\n\n## Draw text\n\n```csharp\ng.DrawText(\"Hello World\", D2DColor.Yellow, this.Font, 100, 200);\n```\n\n## Using brush object\n\n### Solid color brush\n\n```csharp\nvar brush = Device.CreateSolidColorBrush(new D2DColor(1, 0, 0.5));\ng.DrawEllipse(rect, brush);\n```\n\n### Linear and radio gradient brush\n\n```csharp\nvar brush = Device.CreateLinearGradientBrush(new D2DPoint(0, 0), new D2DPoint(200, 100),\n  new D2DGradientStop[] {\n    new D2DGradientStop(0, D2DColor.White),\n    new D2DGradientStop(0.5, D2DColor.Green),\n    new D2DGradientStop(1, D2DColor.Black),\n  });\n```\n\n## Draw bitmap\n\n```csharp\ng.DrawBitmap(bmp, this.ClientRectangle);\n```\n\n### Convert GDI+ bitmap to Direct2D bitmap for getting high-performance rendering\n\n```csharp\n// convert to Direct2D bitmap\nvar d2dbmp = Device.CreateBitmapFromGDIBitmap(gdiBitmap);\n\n// draw Direct2D bitmap\ng.DrawBitmap(d2dbmp, this.ClientRectangle);\n```\n\n### Drawing on GDI+ bitmap\n\n```csharp\n// create and draw on GDI+ bitmap\nvar gdiBmp = new Bitmap(1024, 1024);\nusing (Graphics g = Graphics.FromImage(gdiBmp))\n{\n  g.DrawString(\"This is GDI+ bitmap layer\", new Font(this.Font.FontFamily, 48), Brushes.Black, 10, 10);\n}\n\n// draw memory bitmap on screen\ng.DrawBitmap(gdiBmp, this.ClientRectangle);\n```\n\nLearn more about [Bitmap](https://github.com/jingwood/d2dlib/wiki/Bitmap).\nSee [Example code](src/Examples/Demos/BitmapCustomDraw.cs)\n\n### Drawing on Direct2D memory bitmap\n\n```csharp\nvar bmpGraphics = this.Device.CreateBitmapGraphics(1024, 1024);\nbmpGraphics.BeginRender();\nbmpGraphics.FillRectangle(170, 790, 670, 80, new D2DColor(0.4f, D2DColor.Black));\nbmpGraphics.DrawText(\"This is Direct2D device bitmap\", D2DColor.Goldenrod, this.Font, 180, 800);\nbmpGraphics.EndRender();\n\n// draw this device bitmap on screen\ng.DrawBitmap(bmpGraphics, this.ClientRectangle);\n```\n\n*Note:* When creating a Direct2D Device bitmap, do not forget call `BeginRender` and `EndRender` method.\n\n## Using transform\n\nBy calling `PushTransform` and `PopTransform` to make a transform session.\n\n```csharp\ng.PushTransform();\n\n// rotate 45 degree\ng.RotateTransform(45, centerPoint);\n\ng.DrawBitmap(mybmp, rect);\ng.PopTransform();\n```\n\n# Examples\n\nFast images rendering\n![Image Drawing Test](https://raw.githubusercontent.com/jingwood/d2dlib/master/snapshots/imagetest.png)\nSee [source code](src/Examples/Demos/ImageTest.cs)\n\nCustom draw on memory bitmap\n![Bitmap Custom Draw](https://raw.githubusercontent.com/jingwood/d2dlib/master/snapshots/bitmap_rendering.png)\nSee [source code](src/Examples/Demos/BitmapCustomDraw.cs)\n\nStar space simulation\n![Star Space](https://raw.githubusercontent.com/jingwood/d2dlib/master/snapshots/starspace.png)\nSee [source code](src/Examples/Demos/StarSpace.cs)\n\nSubtitle rendering\n![Subtitle](https://raw.githubusercontent.com/jingwood/d2dlib/master/snapshots/subtitle.png)\nSee [source code](src/Examples/Demos/Subtitle.cs)\n\nWhiteboard App\n![whiteboard](https://raw.githubusercontent.com/jingwood/d2dlib/master/snapshots/whiteboard.png)\\\nSee [source code](src/Examples/Demos/Whiteboard.cs)\n","funding_links":["https://github.com/sponsors/unvell"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingwood%2Fd2dlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjingwood%2Fd2dlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingwood%2Fd2dlib/lists"}