direct2d

Decompose 2D Transformation Matrix

淺唱寂寞╮ 提交于 2019-12-06 09:15:43
问题 So, I have a Direct2D Matrix3x2F that I use to store transformations on geometries. I want these transformations to be user-editable, and I don't want the user to have to edit a matrix directly. Is it possible to decompose a 3x2 matrix into scaling, rotation, skewing, and translation? 回答1: Decomposition yes you can (at least partially). 3x2 transform matrix represents 2D homogenuous 3x3 transform matrix without projections. Such transform matrix is either OpenGL style: | Xx Yx Ox | | Xy Yy Oy

Determine text boundary box with Direct2D/DirectWrite

两盒软妹~` 提交于 2019-12-06 08:25:59
问题 ID2D1RenderTarget::DrawGlyphRun takes the following params: D2D1_POINT_2F baselineOrigin, __in CONST DWRITE_GLYPH_RUN *glyphRun, __in ID2D1Brush *foregroundBrush, DWRITE_MEASURING_MODE measuringMode /*= DWRITE_MEASURING_MODE_NATURAL */ Where DWRITE_GLYPH_RUN is struct DWRITE_GLYPH_RUN { __notnull IDWriteFontFace* fontFace; FLOAT fontEmSize; UINT32 glyphCount; __field_ecount(glyphCount) UINT16 const* glyphIndices; __field_ecount_opt(glyphCount) FLOAT const* glyphAdvances; __field_ecount_opt

Direct2D / GDI+ and slow Windows forms drawing - What can be done?

不打扰是莪最后的温柔 提交于 2019-12-06 04:39:09
问题 I'm working a lot with Visual Studio 2008, .NET C# 2.0-3.5 and Windows Forms and I have noticed, like many before me, that GDI+ is extremely slow in drawing Controls. Note that I do not deal with images (JPG, GIF etc) very much. Images are only as icons in certain places. This is actually Controls/Forms/etc that are slow to draw. The issue is that you can see Controls being drawn and it can take several seconds for a seemingly easy set of Controls to be drawn. Ie, its lagging and horrible. I

how to save bitmap to file using direct2d and ID2D1HwndRenderTarget

我的梦境 提交于 2019-12-05 21:15:16
How to save ID2D1Bitmap to PNG file did not help me. I'm working with Direct2D. I want to save a ID2D1**Hwnd**RenderTarget *m_pRenderTarget to file as bmp or png etc. But the sample I found on MSDN use ID2D1RenderTarget . In my case I drawn my figure in m_pRenderTarget, I used the method ID2D1Bitmap::CopyFromRenderTarget (...) to get an ID2D1Bitmap. After that, to use the saving function bellow, I have to convert the ID2D1Bitmap I got to IWICBitmap . Because the function bellow doesn't use ID2D1Bitmap ... I did not found yet how to do this. thanks. if (SUCCEEDED(hr)) { // // Save image to file

GDI rendering to direct2D ID2D1BitmapRenderTarget is always transparent

五迷三道 提交于 2019-12-05 16:20:11
I want to port my movie rendering software from DirectDraw to Direct2D. Because of compatibility issues, GDI rendering needs to be done on top of the image. To optimize performance I want to implement some kind of backbuffer mechanism, but there seems to be a problem with the alpha channel information, all GDI drawing appears somehow transparent . I create a ID2D1HwndRenderTarget for my window handle and and a ID2D1Bitmap to copy the images to. The pixelformat of the bitmap is DXGI_FORMAT_B8G8R8A8_UNORM , the alpha mode is D2D1_ALPHA_MODE_IGNORE . The HwdRenderTarget is GDI compatible, so my

What are the best practices for multithreading with Direct2D & DXGI (D3D interop)?

…衆ロ難τιáo~ 提交于 2019-12-05 15:39:12
Ideally I'd like to have multiple worker threads to be able to render to off-screen render targets and then 'transfer' the rendered content to the on-screen target. With hwnd render targets this does not seem to be a problem (msdn has an example of it). I'm not quite sure how to do it when the on-screen render target is based on DXGI swap chain. As far as I know, I can only have one swap chain per window. Therefore I can only have a single render target based on the swap chain. This implies that on-screen rendering can only be done through that single render target. If my above assumptions are

Direct2D interface and blurry text issue

感情迁移 提交于 2019-12-05 08:23:37
My new application will feature a rich interface which should be resizable on-the-fly uses transparent icons/images etc. For this application I'm trying to decide on using the new Direct2D API against the good old GDI. One of the downsides is of course it does not run on XP, although I've found a bit nastier issues to decide upon: I noticed that outputting text in a Direct2D environment seems a bit blurry (although marketed as a feature). Just look at the text in Firefox 4 with hardware acceleration enabled (or IE9). It seems to be due to the fact that in Direct2D text does not adhere to the

Determine text boundary box with Direct2D/DirectWrite

浪尽此生 提交于 2019-12-04 14:04:10
ID2D1RenderTarget::DrawGlyphRun takes the following params: D2D1_POINT_2F baselineOrigin, __in CONST DWRITE_GLYPH_RUN *glyphRun, __in ID2D1Brush *foregroundBrush, DWRITE_MEASURING_MODE measuringMode /*= DWRITE_MEASURING_MODE_NATURAL */ Where DWRITE_GLYPH_RUN is struct DWRITE_GLYPH_RUN { __notnull IDWriteFontFace* fontFace; FLOAT fontEmSize; UINT32 glyphCount; __field_ecount(glyphCount) UINT16 const* glyphIndices; __field_ecount_opt(glyphCount) FLOAT const* glyphAdvances; __field_ecount_opt(glyphCount) DWRITE_GLYPH_OFFSET const* glyphOffsets; BOOL isSideways; UINT32 bidiLevel; }; I am trying to

Efficient Direct2D multithreading

☆樱花仙子☆ 提交于 2019-12-04 09:50:09
问题 I'm writing a ebook reader app for Windows Store. I'm using Direct2D + DXGI swap chains to render book pages on screen. My book content sometimes is quite complex (geometry, bitmaps, masks, etc), so it can take up to 100 ms to render it. So I'm trying to do an off-screen rendering to a bitmap in a separate thread, and then just show this bitmap in main thread. However, I can't figure how to do it efficiently. So far I've tried two approaches: Use a single ID2D1Factory with D2D1_FACTORY_TYPE

Resizing Render Target Direct2D after WM_SIZE

自作多情 提交于 2019-12-04 05:51:46
问题 Quick question guys... I am currently working with Directx3D and 2D and I was wondering if I have to recreate the render target when the Windows is resized or does Direct2D automatically detects this, since it's bound to the DXGISurface(back-buffer of the swapchain) when I created it. Here is the code that I used to bind the render targets together: ComPtr<IDXGISurface1> dxgibackBuffer; hr = m_pDxSwapchain->GetBuffer(0, IID_PPV_ARGS(&dxgibackBuffer)); D2D1_BITMAP_PROPERTIES1 bitmapProperties