Not
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Creates a layer resource that can be used with this render target and its compatible render targets.
Syntax
HRESULT CreateLayer(
const D2D1_SIZE_F *size,
ID2D1Layer **layer
);
Parameters
size
Type: [in] const D2D1_SIZE_F*
If (0, 0) is specified, no backing store is created behind the layer resource. The layer resource is allocated to the minimum size when PushLayer is called.
layer
Type: [out] ID2D1Layer**
When the method returns, contains a pointer to a pointer to the new layer. This parameter is passed uninitialized.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
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
| Requirement | Value |
|---|---|
| Target Platform | Windows |
| Header | d2d1.h |
| Library | D2d1.lib |
| DLL | D2d1.dll |