Questions tagged [direct2d]

Direct2D is a hardware-accelerated, immediate-mode, 2-D graphics API that provides high performance and high-quality rendering for 2-D geometry, bitmaps, and text. The Direct2D API is designed to interoperate well with GDI, GDI+, and Direct3D.

738 questions
4
votes
0 answers

How to access bitmap data of Direct2D Hardware RenderTarget?

I'm using Direct2D with for some simple accelerated image compositing/manipulation, and now need to get the pixel data the RenderTarget to pass it to an encoder. So far, I've managed this by rendering to a BitmapRenderTarget, then finally drawing…
Roddy
  • 66,617
  • 42
  • 165
  • 277
4
votes
0 answers

Why is FillGeometry with winding and large coordinates incorrectly filled in Direct2D

I have a MFC program that use Direct2D to paint. Below is a very simple version of the draw method that use FillGeometry to fill a triangle. // AFX_WM_DRAW2D event handler afx_msg LRESULT CChildView::OnDraw2d( WPARAM wParam, LPARAM lParam ) { …
Kennet
  • 323
  • 4
  • 12
4
votes
1 answer

Smooth Video Rendering in C#

I am trying to find a way to render video in WPF with lower CPU usage than MediaElement. The goal is smooth and low CPU video playback as much as Direct3D/DirectDraw video rendering in C++ programming. I tried Direct2D(with WindowsAPICodePack) to…
Aki24x
  • 1,058
  • 1
  • 13
  • 28
4
votes
2 answers

Closest cross-platform alternative to Direct2D/DirectWrite?

What are some good cross-platform alternatives to Windows-specific 2D APIs? I'm looking for an API for rendering simple geometric objects as well as an API for rendering text with subpixel antialiasing (ClearType) and OpenType support, specifically…
Dmitri Nesteruk
  • 23,067
  • 22
  • 97
  • 166
4
votes
0 answers

Line Aliasing with Direct2D like GDI+

I'd like to switch from GDI+ to Direct2D. The main reason for this step is to keep bitmaps in the graphic memory. To achieve a visual compatibility between GDI+ and D2D, the Anti-Aliasing-Mode is switched off for lines and figures (not for text).…
taf
  • 71
  • 4
4
votes
1 answer

How to use direct 2d to draw text in the printer DC?

I use the direct 2d API to draw text in the GDI dc correctly, but When I use the same code to draw text in the printer DC, it failed, The printer hdc is create as below, hdc = CreateDC("WINSPOOL", printerName, "", pdevMode); The Direct 2d draw…
4
votes
2 answers

Direct2D - How to do gamma-correct transparency (alpha) with bitmaps

I'm drawing bitmaps in Direct2D. The bitmaps utilize transparency (alpha channel). The blending looks wrong. As a test I loaded a pure black png image with 50% transparency and drew it over a white background. The result is pixels with a Red, Green,…
Jeff McClintock
  • 1,242
  • 10
  • 27
4
votes
1 answer

How to create a Direct2D factory

I am creating a Direct2D application and the API overview page says the first step is to create a factory... well I tried that with this function D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory); but it gives the error Error 62 …
Display name
  • 721
  • 2
  • 11
  • 29
4
votes
2 answers

Same Direct2D application performs better on a "slower" machine

I wrote a Direct2D application that displays a certain number of graphics. When I run this application it takes about 4 seconds to display 700,000 graphic elements on my notebook: Intel Core i7 CPU Q 720 1.6 GHz NVIDIA Quadro FX 880M According to…
Nick
  • 10,309
  • 21
  • 97
  • 201
4
votes
1 answer

I don't fully understand D2D1_FIGURE_BEGIN: why is it needed, what's the difference, and why does Microsoft's sample code mismatch types anyway?

I'm reading up on Direct2D before I migrate my GDI code to it, and I'm trying to figure out how paths work. I understand most of the work involved with geometries and geometry sinks, but there's one thing I don't understand: the D2D1_FIGURE_BEGIN…
andlabs
  • 11,290
  • 1
  • 31
  • 52
4
votes
1 answer

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…
Nick
  • 10,309
  • 21
  • 97
  • 201
4
votes
2 answers

Direct2D CreateTextLayout() - How to get caret coordinates

I am rendering Text using Direct2D starting with a text Layout HRESULT hr = m_spWriteFactory->CreateTextLayout( m_wsText.c_str( ), m_wsText.length( ), m_spWriteTextFormat.Get( ), m_rect.right - m_rect.left -…
NOhs
  • 2,780
  • 3
  • 25
  • 59
4
votes
1 answer

Applying effects to output instead of bitmaps?

Let's say I have a gaussian blur effect ID2D1Effect *blur; and I want to apply a bitmap to the effect to get a blured image. I can pass the bitmap to the effect using blur->SetInput(0, bitmap); and get the output with blur->Get(). Now I don't want…
Cubi73
  • 1,891
  • 3
  • 31
  • 52
4
votes
1 answer

How to convert a image file loaded in memory to a ID2D1Bitmap in C++

I'm trying to convert a image file (a png, but could be anything) that I just extracted into memory from a compressed file to a ID2D1Bitmap to draw using Direct 2D. I tried to look for some documentation, but I can only find methods that receive…
Guilherme Amorim
  • 445
  • 5
  • 15
4
votes
1 answer

How can I provide a different rendering target to Direct2D?

I'm using Direct2D in C# to render a small gui framework for my research project. I'm not very used to working on Windows or with DirectX. I'm using a Windows Forms control to create a render target, and msdn warns that since it uses BindDC, a the…
fingerprint211b
  • 1,176
  • 12
  • 24