FAQ Database Discussion Community

Direct2D plot approach / performance

How is the approach to plot complex drawings with Direct2D (Sharpdx)? Actually I am using a WindowsRenderTarget, connecting it with a Direct2D1.Factory and drawing to a RenderControl. Factory2D = new SharpDX.Direct2D1.Factory(FactoryType.MultiThreaded); FactoryWrite = new SharpDX.DirectWrite.Factory(); var properties = new HwndRenderTargetProperties(); properties.Hwnd = this.Handle; properties.PixelSize = new Size2(this.ClientSize.Width, this.ClientSize.Height); properties.PresentOptions =...

Screen capture to Direct2D compatible bitmap

I need to capture the screen of a windows given its HWND handle and store the capture in a ID2D1Bitmap object in order to draw this bitmap by means of my render target. How can I achive this result?...

DirectWrite align text center

I am trying to align center the text I have to draw. I use ID2D1RenderTarget::DrawTextLayout method. The problemn is that if I set the text horizontal alignment to DWRITE_TEXT_ALIGNMENT_LEADING (the default value) the text is drawn proberly, but if I change this value to DWRITE_TEXT_ALIGNMENT_CENTER the text is shifted right....

Direct2D bitmap brush elongated

I have to draw my shapes on a offscreen bitmap, but I have a strange problem when I try to render my bitmap. This is how the image should be displayed: And this how I a see the bitmap: Following is the code I use to create the bitmap brush:...

SharpDX DirectWrite rotate text

I wondered how to rotate a text rendered with Direct2D with SharpDX. Can not find any possiblity in RenderTarget2D.DrawText() or RenderTarget2D.DrawTextLayout()...

SharpDX Bitmaps

I've been looking around the internet for a while, and I can't seem to find the answer I've been looking for. So what I intend to do with bitmaps is I want to draw them onto the window, and be able properly resize them whenever. Any help would be appreciated!

Multiple render targets given the same Direct2D factory

I have to draw a lot of shapes by using Direct2D. I use a factory to create a render target I use to draw. Above these shapes I need to add others shapes without changing the previous (freehand drawing), but if I use the same render target I have to...

Direct2d ID2D1HwndRenderTarget->GetSize() returns zero

I've noticed that calling GetSize() on ID2D1HwndRenderTarget returns 0,0 if this call is made after a BeginDraw() call. It returns the correct value otherwise. Is this "normal" behaviour? I haven't seen it documented in any examples. I did spend a few hours scratching my head over this....

Direct2D drawing not working when returning from lock screen

I have an MFC application which is working correctly using Direct2D... except one things : when I lock my computer (Windows) while application is runing, the display is not refreshed anymore whn I unlock computer. Note that the application is runing normally and just resizing the application make it work...

Relationship between AFX_WM_DRAW2D and WM_PAINT in MFC Application

What is the relationship between the two messages in the subject? When exactly the AFX_WM_DRAW2D is passed to application queue. I am asking because I have encountered the strangest recursive call of AFX_WM_DRAW2D handler. Whenever I am trying to paint something inside the AFX_WM_DRAW2Din compatibe render target the handler is...