All Projects β†’ jingwood β†’ D2dlib

jingwood / D2dlib

Licence: mit
A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.

Projects that are alternatives of or similar to D2dlib

Computesharp
A .NET 5 library to run C# code in parallel on the GPU through DX12 and dynamically generated HLSL compute shaders, with the goal of making GPU computing easy to use for all .NET developers! πŸš€
Stars: ✭ 982 (+1069.05%)
Mutual labels:  gpu, library, performance
Media Watermark
GPU/CPU-based iOS Watermark Library for Image and Video Overlay
Stars: ✭ 170 (+102.38%)
Mutual labels:  rendering, gpu, library
powerpaint
Kreative PowerPaint - Library and Application for Bitmap and Vector Image Editing
Stars: ✭ 27 (-67.86%)
Mutual labels:  drawing, bitmap, draw
Libbmp
A simple Bitmap (BMP) library.
Stars: ✭ 30 (-64.29%)
Mutual labels:  library, bitmap
Tvm
Open deep learning compiler stack for cpu, gpu and specialized accelerators
Stars: ✭ 7,494 (+8821.43%)
Mutual labels:  gpu, performance
Werender
Simple, light-weight, Canvas library for 2D rendering
Stars: ✭ 13 (-84.52%)
Mutual labels:  rendering, library
Ascii art
Real-Time ASCII Art Rendering Library
Stars: ✭ 599 (+613.1%)
Mutual labels:  rendering, library
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-57.14%)
Mutual labels:  library, draw
Pencil
Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
Stars: ✭ 968 (+1052.38%)
Mutual labels:  drawing, bitmap
Mpr
Reference implementation for "Massively Parallel Rendering of Complex Closed-Form Implicit Surfaces" (SIGGRAPH 2020)
Stars: ✭ 84 (+0%)
Mutual labels:  rendering, gpu
Vulkan2drenderer
Easy to use 2D rendering engine using Vulkan API as backend.
Stars: ✭ 60 (-28.57%)
Mutual labels:  rendering, library
Pyopencl
OpenCL integration for Python, plus shiny features
Stars: ✭ 790 (+840.48%)
Mutual labels:  gpu, performance
Instacapture
Android library to capture screenshot from your app
Stars: ✭ 681 (+710.71%)
Mutual labels:  library, bitmap
Metalpetal
A GPU accelerated image and video processing framework built on Metal.
Stars: ✭ 907 (+979.76%)
Mutual labels:  rendering, gpu
Dll
Fast Deep Learning Library (DLL) for C++ (ANNs, CNNs, RBMs, DBNs...)
Stars: ✭ 605 (+620.24%)
Mutual labels:  gpu, performance
Mopaint
🎨πŸ’ͺ Modern, modular paint and more! (pre-alpha, not much done yet)
Stars: ✭ 50 (-40.48%)
Mutual labels:  drawing, draw
Maker.js
πŸ“βš™ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+1310.71%)
Mutual labels:  drawing, draw
Reactime
Chrome extension for improving and optimizing performance in React applications (Gatsby and Next.js compatible).
Stars: ✭ 1,219 (+1351.19%)
Mutual labels:  rendering, performance
Gpu Gems Book Source Code
πŸ’Ώ CD Content ( Source Code ) Collection of Book <GPU Gems > 1~ 3 | γ€ŠGPU精粹》 1~ 3 随书CDοΌˆζΊδ»£η οΌ‰ηθ—
Stars: ✭ 567 (+575%)
Mutual labels:  rendering, gpu
Glchaos.p
3D GPUs Strange Attractors and Hypercomplex Fractals explorer - up to 256 Million particles in RealTime
Stars: ✭ 590 (+602.38%)
Mutual labels:  rendering, gpu

NuGet

d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.

By 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.

Project Language Description Output DLL
d2dlib VC++ Wrapper host-side library, calling Windows SDK and Direct2D API d2dlib.dll
d2dlibexport C# Wrapper client-side library, export the interface provided from d2dlib d2dlibexport.dll
d2dwinform C# Provides the D2DWinForm and D2DControl classes that use Direct2D hardware-acceleration graphics context during rendering d2dwinform.dll

Installation

Get binary from NuGet

install-package unvell.d2dlib

Or install for x64 platform:

install-package unvell.d2dlib-x64

Notes

The 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.

Install manually

Learn how to install manually

Getting Started

  1. Make windows form or control inherited from D2DForm or D2DControl class
  2. Override OnRender(D2DGraphics g) method (do not override .NET OnPaint method)
  3. Draw anything inside OnRender method via the g context

Drawing

Draw rectangle

protected override void OnRender(D2DGraphics g)
{
  var rect = new D2DRect(0, 0, 10, 10);
  g.DrawRectangle(rect, D2DColor.Red);
}

Draw ellipse

var ellipse = new D2DEllipse(0, 0, 10, 10);
g.DrawEllipse(ellipse, D2DColor.Gray);

Draw text

g.DrawText("Hello World", D2DColor.Yellow, this.Font, 100, 200);

Using brush object

Solid color brush

var brush = Device.CreateSolidColorBrush(new D2DColor(1, 0, 0.5));
g.DrawEllipse(rect, brush);

Linear and radio gradient brush

var brush = Device.CreateLinearGradientBrush(new D2DPoint(0, 0), new D2DPoint(200, 100),
  new D2DGradientStop[] {
    new D2DGradientStop(0, D2DColor.White),
    new D2DGradientStop(0.5, D2DColor.Green),
    new D2DGradientStop(1, D2DColor.Black),
  });

Draw bitmap

g.DrawBitmap(bmp, this.ClientRectangle);

Convert GDI+ bitmap to Direct2D bitmap for getting high-performance rendering

// convert to Direct2D bitmap
var d2dbmp = Device.CreateBitmapFromGDIBitmap(gdiBitmap);

// draw Direct2D bitmap
g.DrawBitmap(d2dbmp, this.ClientRectangle);

Drawing on GDI+ bitmap

// create and draw on GDI+ bitmap
var gdiBmp = new Bitmap(1024, 1024);
using (Graphics g = Graphics.FromImage(gdiBmp))
{
  g.DrawString("This is GDI+ bitmap layer", new Font(this.Font.FontFamily, 48), Brushes.Black, 10, 10);
}

// draw memory bitmap on screen
g.DrawBitmap(gdiBmp, this.ClientRectangle);

Learn more about Bitmap. See Example code

Drawing on Direct2D memory bitmap

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);

Note: When creating a Direct2D Device bitmap, do not forget call BeginRender and EndRender method.

Using transform

By calling PushTransform and PopTransform to make a transform session.

g.PushTransform();

// rotate 45 degree
g.RotateTransform(45, centerPoint);

g.DrawBitmap(mybmp, rect);
g.PopTransform();

Examples

Fast images rendering Image Drawing Test See source code

Custom draw on memory bitmap Bitmap Custom Draw See source code

Star space simulation Star Space See source code

Subtitle rendering Subtitle See source code

Whiteboard App whiteboard
See source code

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].