Draw and convert bitmaps
masterd2dlib supports high-performance bitmap rendering. You can draw standard GDI+ bitmaps directly, or convert them to Direct2D bitmaps for better performance.
Convert GDI+ to Direct2D
To get high-performance rendering, convert your System.Drawing.Bitmap using Device.CreateBitmapFromGDIBitmap(gdiBitmap) before drawing.
Drawing on Direct2D Memory Bitmaps
You can create a dedicated Direct2D memory bitmap (device bitmap) for custom drawing. When using CreateBitmapGraphics, you must wrap your drawing operations between BeginRender() and EndRender() calls.
// 1. Convert GDI+ bitmap to Direct2D bitmap for high performance
var d2dbmp = Device.CreateBitmapFromGDIBitmap(gdiBitmap);
g.DrawBitmap(d2dbmp, this.ClientRectangle);
// 2. Drawing on a Direct2D memory bitmap
var bmpGraphics = this.Device.CreateBitmapGraphics(1024, 1024);
bmpGraphics.BeginRender(); // Required
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(); // Required
// Draw the resulting device bitmap to the screen
g.DrawBitmap(bmpGraphics, this.ClientRectangle);