Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ID2D1RenderTarget::CreateLayer methods

Creates a layer resource that can be used with this render target and its compatible render targets.

Overload list

MethodDescription
CreateLayer(ID2D1Layer**)

Creates a layer resource that can be used with this render target and its compatible render targets.

CreateLayer(D2D1_SIZE_F,ID2D1Layer**)

Creates a layer resource that can be used with this render target and its compatible render targets. The new layer has the specified initial size.

CreateLayer(D2D1_SIZE_F*,ID2D1Layer**)

Creates a layer resource that can be used with this render target and its compatible render targets. The new layer has the specified initial size.

Remarks

The layer automatically resizes itself, as needed.

Examples

The following example uses a layer to clip a bitmap to a geometric mask. For the complete example, see How to Clip to a Geometric Mask.


HRESULT DemoApp::RenderWithLayer(ID2D1RenderTarget *pRT)
{
    HRESULT hr = S_OK;

    // Create a layer.
    ID2D1Layer *pLayer = NULL;
    hr = pRT->CreateLayer(NULL, &pLayer);

    if (SUCCEEDED(hr))
    {
        pRT->SetTransform(D2D1::Matrix3x2F::Translation(350, 50));

        // Push the layer with the geometric mask.
        pRT->PushLayer(
            D2D1::LayerParameters(D2D1::InfiniteRect(), m_pPathGeometry),
            pLayer
            );
            
  
        pRT->DrawBitmap(m_pOrigBitmap, D2D1::RectF(0, 0, 200, 133));
        pRT->FillRectangle(D2D1::RectF(0.f, 0.f, 25.f, 25.f), m_pSolidColorBrush);  
        pRT->FillRectangle(D2D1::RectF(25.f, 25.f, 50.f, 50.f), m_pSolidColorBrush);
        pRT->FillRectangle(D2D1::RectF(50.f, 50.f, 75.f, 75.f), m_pSolidColorBrush); 
        pRT->FillRectangle(D2D1::RectF(75.f, 75.f, 100.f, 100.f), m_pSolidColorBrush);    
        pRT->FillRectangle(D2D1::RectF(100.f, 100.f, 125.f, 125.f), m_pSolidColorBrush); 
        pRT->FillRectangle(D2D1::RectF(125.f, 125.f, 150.f, 150.f), m_pSolidColorBrush);    
        

        pRT->PopLayer();
    }

    SafeRelease(&pLayer);

    return hr;
}


Requirements

Library

D2d1.lib

DLL

D2d1.dll

See also

Layers Overview
ID2D1RenderTarget

 

 

Community Additions

ADD
Show:
© 2015 Microsoft