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 IInkD2DRenderer interface inherits from the IUnknown interface. IInkD2DRenderer also has these types of members:

Methods

The IInkD2DRenderer interface has these methods.

MethodDescription
Draw

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

 

Creation\Access Functions

Use the following to retrieve a reference to the object:

CoCreateInstance

Call CoCreateInstance with the class identifier InkD2DRenderer.

This snippet is taken from the "InkRenderer.cpp" file of the Complex ink sample.


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

 

Examples

This snippet from the "SceneComposer.cpp" file of the Complex ink 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 ink 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

Minimum supported client

Windows 10

Minimum supported server

None supported

Header

Inkrenderer.h

IDL

Inkrenderer.idl

IID

IID_IInkD2DRenderer is defined as 407fb1de-f85a-4150-97cf-b7fb274fb4f8

See also

Ink renderer interfaces
Pen and stylus interactions
Samples
Ink sample
Simple ink sample
Complex ink sample

 

 

Show: