InkD2DRenderer class

Implements the IInkD2DRenderer interface.

An IInkD2DRenderer object enables the rendering of ink strokes onto the designated Direct2D device context of a Universal Windows app, instead of the default InkCanvas control.

Members

The InkD2DRenderer class inherits from the IUnknown interface. InkD2DRenderer also has these types of members:

Methods

The InkD2DRenderer class has these methods.

Method Description
Draw Renders the ink stroke to the designated Direct2D device context of the app.

Creation\Access Functions

Call CoCreateInstance with the class identifier InkD2DRenderer to retrieve a reference to the object.

CoCreateInstance(__uuidof(InkD2DRenderer),
  nullptr,
  CLSCTX_INPROC_SERVER,
  IID_PPV_ARGS(&_spInkD2DRenderer));

Examples

This snippet from the "SceneComposer.cpp" file of the Complex inking sample demonstrates the rendering of a collection of ink strokes to a Direct2D device context.

_inkRenderer->Render(strokes, _deviceResources->GetD2DDeviceContext());
strokes->Clear();

This snippet from the "InkRenderer.cpp" file of the Complex inking sample shows the Render method (called in the previous snippet) that calls the Draw method for rendering the strokes.

void InkRenderer::Render(
    Platform::Collections::Vector<
        Windows::UI::Input::Inking::InkStroke^>^ strokes,
        Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2dContext)
{
    HRESULT hr = S_OK;
    if (_spInkD2DRenderer != nullptr)
    {
        if (strokes != nullptr && strokes->Size > 0)
        {
            // Cast the stroke collection into IUnknown to call Inkd2dRenderer
            ComPtr<IUnknown> spUnkStrokes = 
                reinterpret_cast<IUnknown*>(reinterpret_cast<__abi_IUnknown*>(strokes));
            hr = _spInkD2DRenderer->Draw(d2dContext.Get(), spUnkStrokes.Get(), false);
            if (FAILED(hr))
            {
                DX::ThrowIfFailed(hr);
            }
        }
    }
}

Requirements

Requirement Value
Minimum supported client
Windows 10 [desktop apps only]
Minimum supported server
None supported
Header
Inkrenderer.h
IDL
Inkrenderer.idl
IID
IID_IInkD2DRenderer is defined as 4044e60c-7b01-4671-a97c-04e0210a07a5

Ink renderer, Pen and stylus interactions, Ink Analysis sample, Simple inking sample, Complex inking sample